-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from bjhargrave/harden-workflows
Harden GitHub action workflows
- Loading branch information
Showing
7 changed files
with
119 additions
and
46 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# GitHub Dependabot configuration file | ||
version: 2 | ||
updates: | ||
|
||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
|
||
# Maintain dependencies for Python scripts | ||
- package-ecosystem: "pip" | ||
directory: "/tools/maintainers" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "actionlint", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$", | ||
"file": 1, | ||
"line": 2, | ||
"column": 3, | ||
"message": 4, | ||
"code": 5 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,67 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Periodic update of MAINTAINERS.md | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * *' # Runs every day at 00:00 UTC | ||
workflow_dispatch: # Allow manual trigger | ||
|
||
env: | ||
LC_ALL: en_US.UTF-8 | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
update-maintainers: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
- name: "Harden Runner" | ||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1 | ||
with: | ||
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs | ||
|
||
- name: Run script | ||
run: ./tools/maintainers/maintainers.py tools/maintainers/teams.yaml > MAINTAINERS.md | ||
- name: "Checkout" | ||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: "Setup Python" | ||
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 | ||
with: | ||
python-version: "3.11" | ||
|
||
- name: "Install Python Packages" | ||
run: | | ||
pip install -r tools/maintainers/requirements.txt | ||
- name: Update maintainers page | ||
run: | | ||
tools/maintainers/maintainers.py tools/maintainers/teams.yaml > MAINTAINERS.md | ||
env: | ||
GH_TOKEN: ${{ secrets.ORG_ACCESS_TOKEN }} | ||
|
||
- name: Check for changes | ||
id: git-diff | ||
run: echo "CHANGED=$(if git diff --quiet --exit-code; then echo "false"; else echo "true"; fi)" >> "$GITHUB_ENV" | ||
|
||
- name: Commit and push if changed | ||
if: env.CHANGED == 'true' | ||
run: | | ||
git config --global user.name 'Maintainers Update Bot' | ||
git config --global user.email '[email protected]' | ||
git commit -a -s -m "MAINTAINERS.md: automated update" | ||
git push -f origin HEAD:maintainers-update | ||
echo "changed=$(git diff --quiet --exit-code -- MAINTAINERS.md; echo "$?")" >> "$GITHUB_OUTPUT" | ||
- name: Create Pull Request | ||
if: env.CHANGED == 'true' | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: "Commit message" | ||
title: "MAINTAINERS.md: automated update" | ||
body: "Automated update of MAINTAINERS.md" | ||
branch: "maintainers-update" | ||
if: steps.git-diff.outputs.changed == '1' | ||
run: | | ||
git config --global user.name 'Maintainers Update Bot' | ||
git config --global user.email '[email protected]' | ||
git checkout -b maintainers-update | ||
git add -- MAINTAINERS.md | ||
git commit -s -m "MAINTAINERS.md: automated update" | ||
git push -u -f origin maintainers-update | ||
if ! (gh pr list --head maintainers-update --json number | grep -q "number") ; then | ||
gh pr create --title "MAINTAINERS.md: automated update" --body "Automated update of MAINTAINERS.md" | ||
fi | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
PyYAML>=6.0.1,<7.0.0 | ||
requests>=2.31.0,<3.0.0 |