|
1 | 1 | #!/bin/sh |
2 | 2 | # Rationale: |
3 | | -# Ci-starter has the subcommand update-actions to update an end-user's project's workflow files to that they |
4 | | -# use the latest versions of the GitHub actions. This updates the actions in all of the end-user's project's |
5 | | -# workflow files, regardless whether these workflow files have been created with ci-starter or manually. |
6 | | -# |
| 3 | +# Ci-starter's subcommand update-actions updates an end-user's project's workflow files so that they |
| 4 | +# use the latest versions of the GitHub actions. This updates the action versions in all of the end-user's |
| 5 | +# project's workflow files, regardless whether these workflow files have been created with ci-starter or |
| 6 | +# manually. |
| 7 | +# |
7 | 8 | # Ci-starter project has an end-to-end test where we test if this update-actions subcommand works properly. |
8 | 9 | # In that test we check if the handful of actions ci-starter uses in its workflow templates are updated |
9 | | -# correctly and match their respective expeced commit SHA and version. The expected current commit SHA |
| 10 | +# correctly and match their respective expected commit SHA and version. The expected current commit SHA |
10 | 11 | # and version of each GitHub action needs to be hard-coded in the end-to-end test. |
11 | 12 | # However, as time goes on, the expected commit SHAs and versions of the updated actions from ci-starter's |
12 | 13 | # templates change because these actions, too, are getting new releases from time to time. |
13 | 14 | # |
14 | 15 | # The maintainer of the ci-starter project needs a way to update the end-to-end test's code |
15 | | -# so that the expected versions match the actual current version of the actions. Doing this manually is |
16 | | -# cumbersome. This script was written to update the code of the end-to-end test of the |
17 | | -# update-actions subcommand programatically. |
| 16 | +# so that the expected versions match the actual current versions of the actions. Doing this manually is |
| 17 | +# cumbersome. This script was written to update the code of the end-to-end test of the update-actions |
| 18 | +# subcommand programatically. |
18 | 19 | # |
19 | 20 | # Usage: |
20 | 21 | # - make sure you are in the ci-starter's project directory |
21 | 22 | # - uv executable is in $PATH |
22 | 23 | # - ci-starter project is installed with the lint dev-dependency group |
23 | | -# - for frequent use provide a GitHub personal access token to avoid getting rate-limited |
| 24 | +# - provide a GitHub personal access token to avoid getting rate-limited: |
24 | 25 | # CI_STARTER_GH_API_TOKEN=<your-access-token-for-github> ./scripts/update-test_update_actions.sh |
25 | 26 |
|
26 | 27 | WORKFLOWS=./.github/workflows |
27 | 28 | TEST_FILE=./tests/e2e/test_update_actions.py |
28 | 29 |
|
29 | | -actions_from_all_workflows() { |
| 30 | +find_lines_where_action_is_pinned_to_sha_and_commented_with_version() { |
30 | 31 | find "$WORKFLOWS" -type f -name "*.yml" \ |
31 | 32 | | xargs sed -nE 's$uses: ([^[:space:]]+)/([^[:space:]]+)@([0-9a-f]{40}) # v([^[:space:]]+)$\1 \2 \3 \4$p' \ |
32 | 33 | | sort | uniq |
33 | 34 | } |
34 | 35 |
|
35 | 36 | get_actions_from_all_workflows_with_their_latest_commits_and_versions() { |
36 | | - actions_from_all_workflows | while read owner repo old_commit old_version; do |
| 37 | + find_lines_where_action_is_pinned_to_sha_and_commented_with_version | while read owner repo old_commit old_version; do |
37 | 38 | url="https://api.github.com/repos/$owner/$repo/tags" |
38 | 39 |
|
39 | 40 | if [ -n "$CI_STARTER_GH_API_TOKEN" ]; then |
|
0 commit comments