Skip to content

Commit 91ad943

Browse files
authored
Rename api_token to api-token; add versioning CI; update readme (#21)
* rename: `api_token` secret to `api-token` * chore: add versioning CI & update readme
1 parent 1068f37 commit 91ad943

File tree

4 files changed

+84
-57
lines changed

4 files changed

+84
-57
lines changed

.github/workflows/updater.yml

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,4 @@
11
# Allows updating dependencies to the latest published tag
2-
#
3-
# Example workflow definition:
4-
# name: Update Dependencies
5-
# on:
6-
# # Run every day.
7-
# schedule:
8-
# - cron: '0 3 * * *'
9-
# # And on on every PR merge so we get the updated dependencies ASAP, and to make sure the changelog doesn't conflict.
10-
# push:
11-
# branches:
12-
# - main
13-
# jobs:
14-
# # Update a git submodule
15-
# cocoa:
16-
# uses: getsentry/github-workflows/.github/workflows/updater.yml@v1
17-
# with:
18-
# path: modules/sentry-cocoa
19-
# name: Cocoa SDK
20-
# pattern: '^1\.' # Limit to major version '1'
21-
# secrets:
22-
# api_token: ${{ secrets.CI_DEPLOY_KEY }}
23-
#
24-
# # Update a properties file
25-
# cli:
26-
# uses: getsentry/github-workflows/.github/workflows/updater.yml@v1
27-
# with:
28-
# path: sentry-cli.properties
29-
# name: CLI
30-
# secrets:
31-
# api_token: ${{ secrets.CI_DEPLOY_KEY }}
32-
#
33-
# # Update using a custom shell script, see scripts/update-dependency.ps1 for the required arguments
34-
# agp:
35-
# uses: getsentry/github-workflows/.github/workflows/updater.yml@v1
36-
# with:
37-
# path: script.ps1
38-
# name: Gradle Plugin
39-
# secrets:
40-
# api_token: ${{ secrets.CI_DEPLOY_KEY }}
412
on:
423
workflow_call:
434
inputs:
@@ -70,7 +31,7 @@ on:
7031
required: false
7132
default: v1 # Note: update when publishing a new version
7233
secrets:
73-
api_token:
34+
api-token:
7435
required: true
7536
outputs:
7637
prUrl:
@@ -131,7 +92,7 @@ jobs:
13192
steps:
13293
- uses: actions/checkout@v3
13394
with:
134-
ssh-key: ${{ secrets.api_token }}
95+
ssh-key: ${{ secrets.api-token }}
13596

13697
# In order to run scripts from this repo, we need to check it out manually, doesn't seem available locally.
13798
- name: Check out workflow scripts
@@ -249,7 +210,7 @@ jobs:
249210
if: ${{ ( steps.target.outputs.latestTag != steps.target.outputs.originalTag ) && ( steps.existing-pr.outputs.url == '') }}
250211
uses: actions/checkout@v3
251212
with:
252-
ssh-key: ${{ secrets.api_token }}
213+
ssh-key: ${{ secrets.api-token }}
253214

254215
- name: 'After new PR: redo the update'
255216
if: ${{ ( steps.target.outputs.latestTag != steps.target.outputs.originalTag ) && ( steps.existing-pr.outputs.url == '') }}

.github/workflows/versioning.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Keep the major version tags up-to-date
2+
3+
on:
4+
release:
5+
types: [published, edited]
6+
7+
jobs:
8+
actions-tagger:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: Actions-R-Us/actions-tagger@f411bd910a5ad370d4511517e3eac7ff887c90ea # v2.0.2
12+
with:
13+
publish_latest_tag: true

.github/workflows/workflow-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
pattern: '^2\.0\.'
1414
_workflow_version: ${{ github.sha }}
1515
secrets:
16-
api_token: ${{ github.token }}
16+
api-token: ${{ github.token }}
1717

1818
test-args:
1919
uses: ./.github/workflows/updater.yml
@@ -23,7 +23,7 @@ jobs:
2323
runs-on: macos-latest
2424
_workflow_version: ${{ github.sha }}
2525
secrets:
26-
api_token: ${{ github.token }}
26+
api-token: ${{ github.token }}
2727

2828
test-outputs:
2929
runs-on: ubuntu-latest

README.md

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,75 @@
22

33
This repository contains reusable workflows and scripts to be used with GitHub Actions.
44

5-
For versioning, we're using a shifting tag strategy, with the current version tag - e.g. `v1` - being updated until
6-
there's a breaking change, at which point it will stay as is and we start using a new tag, `v2`, etc...
5+
## Updater
76

8-
This allows consumers to be on the latest version of a compatible workflow. If you prefer, you can instead pin to a
9-
specific commit.
7+
Dependency updater - see [updater.yml](.github/workflows/updater.yml) - updates dependencies to the latest published git tag.
108

11-
## Contributing
9+
### Example workflow definition
1210

13-
Note on versioning: Reusable workflows don't support version selection based on the major version specified
14-
by the user - instead, an exact ref is needed, that's why we have to shift the tag as needed.
11+
```yaml
12+
name: Update Dependencies
13+
on:
14+
# Run every day.
15+
schedule:
16+
- cron: '0 3 * * *'
17+
# And on on every PR merge so we get the updated dependencies ASAP, and to make sure the changelog doesn't conflict.
18+
push:
19+
branches:
20+
- main
21+
jobs:
22+
# Update a git submodule
23+
cocoa:
24+
uses: getsentry/github-workflows/.github/workflows/updater.yml@v2
25+
with:
26+
path: modules/sentry-cocoa
27+
name: Cocoa SDK
28+
pattern: '^1\.' # Limit to major version '1'
29+
secrets:
30+
api-token: ${{ secrets.CI_DEPLOY_KEY }}
1531

16-
To shift the tag to the current commit:
32+
# Update a properties file
33+
cli:
34+
uses: getsentry/github-workflows/.github/workflows/updater.yml@v2
35+
with:
36+
path: sentry-cli.properties
37+
name: CLI
38+
secrets:
39+
api-token: ${{ secrets.CI_DEPLOY_KEY }}
1740

18-
```shell-script
19-
git push
20-
git tag -d v1
21-
git tag v1
22-
git push --tags --force
41+
# Update using a custom shell script, see scripts/update-dependency.ps1 for the required arguments
42+
agp:
43+
uses: getsentry/github-workflows/.github/workflows/updater.yml@v2
44+
with:
45+
path: script.ps1
46+
name: Gradle Plugin
47+
secrets:
48+
api-token: ${{ secrets.CI_DEPLOY_KEY }}
2349
```
50+
51+
### Inputs
52+
53+
* `path`: Dependency path in the source repository, this can be either a submodule, a .properties file or a shell script.
54+
* type: string
55+
* required: true
56+
* `name`: Name used for a changelog entry.
57+
* type: string
58+
* required: true
59+
* `pattern`: RegEx pattern that will be matched against available versions when picking the latest one.
60+
* type: string
61+
* required: false
62+
* default: ''
63+
* `changelog-section`: Section header to attach the changelog entry to.
64+
* type: string
65+
* required: false
66+
* default: Dependencies
67+
* `runs-on`: GitHub Actions virtual environment name to run the udpater job on.
68+
* type: string
69+
* required: false
70+
* default: ubuntu-latest
71+
72+
### Secrets
73+
74+
* `api-token`: GH authentication token to create PRs with & push.
75+
If you provide the usual `${{ github.token }}`, no followup CI will run on the created PR.
76+
If you want CI to run on the PRs created by the Updater, you need to provide custom user-specific auth token.

0 commit comments

Comments
 (0)