Skip to content

Commit 397291d

Browse files
bug fix version bump 0.7.1-draft (#305)
* feat 🚀 add test for gitlab repo (#278) * feat 🚀 add test for gitlab repo (#278) * feat 🚀 add test for gitlab repo (#278) * doc: 📝 document the usage of other git providers (#278) * release(v0.7.1-draft): 🚀 bug fix release (#278)
1 parent e8b7f32 commit 397291d

File tree

5 files changed

+51
-10
lines changed

5 files changed

+51
-10
lines changed

.github/workflows/actions_template_sync.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Checkout
1717
uses: actions/checkout@v3
1818
- name: actions-template-sync
19-
uses: AndreasAugustin/[email protected].0-draft
19+
uses: AndreasAugustin/[email protected].1-draft
2020
with:
2121
github_token: ${{ secrets.GITHUB_TOKEN }}
2222
source_repo_path: AndreasAugustin/template

.github/workflows/test_ssh_gitlab.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: test-ssh-gitlab
2+
3+
on:
4+
pull_request:
5+
push:
6+
# manual trigger
7+
workflow_dispatch:
8+
9+
jobs:
10+
test-implementation-job:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
# To use this repository's private action, you must check out the repository
16+
-
17+
name: Checkout
18+
uses: actions/checkout@v3
19+
-
20+
name: Test action step ssh
21+
uses: ./ # Uses an action in the root directory
22+
with:
23+
hostname: ${{ secrets.SOURCE_REPO_GITLAB_HOSTNAME }}
24+
github_token: ${{ secrets.GITHUB_TOKEN }}
25+
source_repo_path: ${{ secrets.SOURCE_REPO_GITLAB_PATH }} # <owner/repo>, should be within secrets
26+
source_repo_ssh_private_key: ${{ secrets.SOURCE_REPO_GITLAB_SSH_PRIVATE_KEY }} # contains the private ssh key of the private repository
27+
is_dry_run: true
28+
is_not_source_github: true

README.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,10 @@ This GitHub action will help you to keep track of the template changes.
3232
* Ignore files and folders from syncing using a `.templatesyncignore` file
3333
* many configuration options
3434
* different lifecycle hooks are supported
35+
* different git provider. Default is GitHub, GitLab is also tested. See [.github/workflows/test_ssh_gitlab.yml] for an example.
3536

3637
## Usage
3738

38-
### Update
39-
40-
starting with version v0.5.2-draft the `templateversionrc` file is not needed anymore. You can delete that file from the target repositories.
41-
4239
### Public template repository
4340

4441
Add this configuration to your github action
@@ -61,7 +58,7 @@ jobs:
6158
- name: Checkout
6259
uses: actions/checkout@v3
6360
- name: actions-template-sync
64-
uses: AndreasAugustin/[email protected].0-draft
61+
uses: AndreasAugustin/[email protected].1-draft
6562
with:
6663
github_token: ${{ secrets.GITHUB_TOKEN }}
6764
source_repo_path: <owner/repo>
@@ -94,7 +91,7 @@ jobs:
9491
private_key: ${{ secrets.PRIVATE_KEY }}
9592

9693
- name: actions-template-sync
97-
uses: AndreasAugustin/[email protected].0-draft
94+
uses: AndreasAugustin/[email protected].1-draft
9895
with:
9996
github_token: ${{ steps.generate_token.outputs.token }}
10097
source_repo_path: <owner/repo>
@@ -109,6 +106,7 @@ An example are [deployment keys][deployment-keys]. For our use case write permis
109106
Within the repository where the GitHub action is enabled add a secret (e.q. `SOURCE_REPO_SSH_PRIVATE_KEY`) with the content of your private SSH key.
110107
Make sure that the read permissions of that secret fulfil your use case.
111108
Set the optional `source_repo_ssh_private_key` input parameter.
109+
It is also possible to use a different git provider, e.g. GitLab.
112110

113111
```yaml
114112
jobs:
@@ -120,7 +118,7 @@ jobs:
120118
- name: Checkout
121119
uses: actions/checkout@v3
122120
- name: actions-template-sync
123-
uses: AndreasAugustin/[email protected].0-draft
121+
uses: AndreasAugustin/[email protected].1-draft
124122
with:
125123
github_token: ${{ secrets.GITHUB_TOKEN }}
126124
source_repo_path: ${{ secrets.SOURCE_REPO_PATH }} # <owner/repo>, should be within secrets
@@ -144,6 +142,7 @@ jobs:
144142
| hostname | `[optional]` the hostname of the repository | `false` | `github.com` |
145143
| is_dry_run | `[optional]` set to `true` if you do not want to push the changes and not want to create a PR | `false` | |
146144
| is_allow_hooks | `[optional]` set to `true` if you want to enable lifecycle hooks. Use this with caution! | `false` | `false` |
145+
| is_not_source_github | `[optional]` set to `true` if the source git provider is not GitHub | `false` | `false` |
147146

148147
### Example
149148

@@ -220,6 +219,10 @@ To ignore those, simply create a file in the root directory named `.templatesync
220219
Open your project `Settings > Actions > General` and select the checkbox `Allow Github Actions to create and approve pull requests`
221220
under the `Workflow permissions` section.
222221

222+
## Release Updates
223+
224+
starting with version v0.5.2-draft the `templateversionrc` file is not needed anymore. You can delete that file from the target repositories.
225+
223226
## Debug
224227

225228
You must create a secret named `ACTIONS_STEP_DEBUG` with the value `true` to see the debug messages set by this command in the log.

action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ inputs:
3636
is_allow_hooks:
3737
description: '[optional] set to true if you want to allow hooks. Use this functionality with caution!'
3838
default: 'false'
39+
is_not_source_github:
40+
description: '[optional] set to true if the source repository is not a github related repository. Useful e.q. if the source is GitLab'
41+
default: 'false'
3942
runs:
4043
using: 'docker'
4144
image: 'src/Dockerfile'
@@ -51,3 +54,4 @@ runs:
5154
HOSTNAME: ${{ inputs.hostname }}
5255
IS_DRY_RUN: ${{ inputs.is_dry_run }}
5356
IS_ALLOW_HOOKS: ${{ inputs.is_allow_hooks }}
57+
IS_NOT_SOURCE_GITHUB: ${{ inputs.is_not_source_github }}

src/entrypoint.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ function git_init() {
5858
git config --global --add safe.directory /github/workspace
5959
git lfs install
6060

61-
gh auth setup-git --hostname "${SOURCE_REPO_HOSTNAME}"
62-
gh auth status --hostname "${SOURCE_REPO_HOSTNAME}"
61+
if [[ -n "${IS_NOT_SOURCE_GITHUB}" ]]; then
62+
info "the source repository is not located within GitHub."
63+
ssh-keyscan -t rsa "${SOURCE_REPO_HOSTNAME}" >> /root/.ssh/known_hosts
64+
else
65+
info "the source repository is located within GitHub."
66+
gh auth setup-git --hostname "${SOURCE_REPO_HOSTNAME}"
67+
gh auth status --hostname "${SOURCE_REPO_HOSTNAME}"
68+
fi
6369
echo "::endgroup::"
6470
}
6571

0 commit comments

Comments
 (0)