Skip to content

Commit 184608c

Browse files
committed
Use Dependabot to check for outdated action versions used in workflows
Dependabot will periodically check the GitHub Actions workflows and workflow templates of the repository and submit pull requests to update any that are found to be using an outdated version of an action. This check has previously been a manual process, and a frequently neglected one. Up to date action versions are especially important in the workflow templates, since they are the source for the CI systems of many repositories. Typically, the best approach is to only pin the major version of the action (e.g., `uses: foo/bar@v1`), so the workflow will automatically use the latest version of the action except when there have been breaking changes. Many actions provide major version refs for this purpose. NOTE: Dependabot's PRs will occasionally try to pin to the patch version of the action (e.g., updating `uses: foo/bar@v1` to `uses: foo/[email protected]`). When the action author has provided a major version ref, use that instead (e.g., `uses: foo/bar@v2`). Once the major version has been updated in the workflow, Dependabot should not submit an update PR again until the next major version bump. So even if the PRs from Dependabot are not always exactly correct, their value lies in bringing the maintainer's attention to the fact that the action version in use is outdated. Dependabot will automatically close its PR once the workflow has been updated. In the case of PRs from Dependabot for updates to the workflow template copies, these serve solely as update notifications Dependabot has been configured to prefix the PR message with "(DO NOT MERGE)" to make this clear. I have configured Dependabot to assign me to these pull requests and will take responsibility for reviewing and testing them. --- In addition to setting up Dependabot for this repository, I have also provided a template Dependabot configuration file and documentation to make it easy to setting this up in other repositories where the maintainers have determined it would be useful.
1 parent 4ca6fa6 commit 184608c

File tree

5 files changed

+131
-0
lines changed

5 files changed

+131
-0
lines changed

.github/dependabot.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# See: https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#about-the-dependabotyml-file
2+
version: 2
3+
4+
updates:
5+
# Configure check for outdated GitHub Actions actions in workflows.
6+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/dependabot/README.md
7+
# See: https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot
8+
- package-ecosystem: github-actions
9+
directory: / # Check the repository's workflows under /.github/workflows/
10+
schedule:
11+
interval: daily
12+
labels:
13+
- "topic: infrastructure"
14+
assignees:
15+
- per1234
16+
17+
# Configure check for outdated GitHub Actions actions in workflow templates.
18+
- package-ecosystem: github-actions
19+
# The workflows under the .github/workflows/ subfolder of this path will be checked.
20+
directory: /workflow-templates/dependabot/workflow-template-copies/
21+
schedule:
22+
interval: daily
23+
commit-message:
24+
prefix: (DO NOT MERGE)
25+
labels:
26+
- "topic: infrastructure"
27+
assignees:
28+
- per1234

.github/workflows/check-sync.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This repository contains intentionally duplicated copies of files:
2+
# - Workflow template copies under workflow-templates/dependabot/workflow-template-copies used for Dependabot checks.
3+
# - Workflow template copies in .github/workflows used for this repository's own CI system.
4+
# - Assets for the workflow templates used in this repository.
5+
#
6+
# This workflow checks that the copies are in sync.
7+
# If the workflow fails, run workflow-templates/etc/sync.sh and commit.
8+
9+
name: Check File Duplicates Sync
10+
11+
on:
12+
push:
13+
pull_request:
14+
15+
jobs:
16+
check-sync:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v2
22+
23+
- name: Check file duplicates sync
24+
run: |
25+
SYNC_SCRIPT_PATH="etc/sync.sh"
26+
"${{ github.workspace }}/$SYNC_SCRIPT_PATH"
27+
git add .
28+
if ! git diff --color --exit-code HEAD; then
29+
echo "::error::File duplicates are out of sync. Please run $SYNC_SCRIPT_PATH"
30+
exit 1
31+
fi

etc/sync.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
# Sync the repository's intentionally duplicated files.
3+
4+
readonly REPOSITORY_ROOT_PATH="$(git rev-parse --show-toplevel)"
5+
readonly WORKFLOW_TEMPLATE_ASSETS_PATH="${REPOSITORY_ROOT_PATH}/workflow-templates/assets"
6+
readonly WORKFLOW_TEMPLATES_PATH="${REPOSITORY_ROOT_PATH}/workflow-templates"
7+
readonly WORKFLOWS_PATH="${REPOSITORY_ROOT_PATH}/.github/workflows"
8+
readonly WORKFLOW_TEMPLATE_COPIES_PATH="${REPOSITORY_ROOT_PATH}/workflow-templates/dependabot/workflow-template-copies/.github/workflows"
9+
10+
# Sync workflow templates with the copies in the folder where Dependabot can check them for updates.
11+
mkdir --parents "$WORKFLOW_TEMPLATE_COPIES_PATH"
12+
rm --force "${WORKFLOW_TEMPLATE_COPIES_PATH}/"*
13+
find "$WORKFLOW_TEMPLATES_PATH" -maxdepth 1 -type f -and \( -name '*.yml' -or -name '*.yaml' \) -exec cp '{}' "$WORKFLOW_TEMPLATE_COPIES_PATH" \;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Dependabot for GitHub Actions
2+
3+
Dependabot can be used to check for outdated action versions used in the repository's GitHub Actions workflows:
4+
5+
https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot
6+
7+
## Instructions
8+
9+
Just copy [this `dependabot.yml` file](dependabot.yml) to the `.github/` folder of the target repository (or add the entry if the repository already has a `/.github/dependabot.yml`) and everything else is handled automatically.
10+
11+
### Note
12+
13+
Dependabot's PRs will occasionally propose to pin to the patch version of the action (e.g., updating `uses: foo/bar@v1` to `uses: foo/[email protected]`). When the action author has [provided a major version ref](https://docs.github.com/en/actions/creating-actions/about-actions#using-release-management-for-actions), use that instead (e.g., `uses: foo/bar@v2`). Once the major version has been updated in the workflow, Dependabot should not submit an update PR again until the next major version bump.
14+
15+
So even when the PRs from Dependabot are not exactly correct, they still have value in bringing the maintainer's attention to the fact that the action version in use is outdated. The effort needed to manually adjust the ref when this happens is trivial.
16+
17+
Dependabot will automatically close its PR once the workflow has been updated.
18+
19+
## Commit message
20+
21+
```
22+
Configure Dependabot to check for outdated actions used in workflows
23+
24+
Dependabot will periodically check the versions of all actions used in the repository's workflows. If any are found to
25+
be outdated, it will submit a pull request to update them.
26+
27+
NOTE: Dependabot's PRs will occasionally propose to pin to the patch version of the action (e.g., updating
28+
`uses: foo/bar@v1` to `uses: foo/[email protected]`). When the action author has provided a major version ref, use that instead
29+
(e.g., `uses: foo/bar@v2`). Dependabot will automatically close its PR once the workflow has been updated.
30+
31+
More information:
32+
https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot
33+
```
34+
35+
## PR message
36+
37+
```Markdown
38+
Dependabot will periodically check the versions of all actions used in the repository's workflows. If any are found to be outdated, it will submit a pull request to update them.
39+
40+
NOTE: Dependabot's PRs will occasionally propose to pin to the patch version of the action (e.g., updating `uses: foo/bar@v1` to `uses: foo/[email protected]`). When the action author has [provided a major version ref](https://docs.github.com/en/actions/creating-actions/about-actions#using-release-management-for-actions), use that instead (e.g., `uses: foo/bar@v2`). Once the major version has been updated in the workflow, Dependabot should not submit an update PR again until the next major version bump.
41+
42+
So even when the PRs from Dependabot are not exactly correct, they still have value in bringing the maintainer's attention to the fact that the action version in use is outdated. Dependabot will automatically close its PR once the workflow has been updated.
43+
44+
More information:
45+
https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot
46+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# See: https://docs.github.com/en/code-security/supply-chain-security/configuration-options-for-dependency-updates#about-the-dependabotyml-file
2+
version: 2
3+
4+
updates:
5+
# Configure check for outdated GitHub Actions actions in workflows.
6+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/dependabot/README.md
7+
# See: https://docs.github.com/en/code-security/supply-chain-security/keeping-your-actions-up-to-date-with-dependabot
8+
- package-ecosystem: github-actions
9+
directory: / # Check the repository's workflows under /.github/workflows/
10+
schedule:
11+
interval: daily
12+
labels:
13+
- "topic: infrastructure"

0 commit comments

Comments
 (0)