-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: workflow to update actions dist #3653
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f5e5d92
add workdflow to update dists
ramonpetgrave64 a41d299
add docs, use env for input
ramonpetgrave64 562a87d
also signoff
ramonpetgrave64 8d00392
toc
ramonpetgrave64 c437da5
license
ramonpetgrave64 728a169
update shellcheck to fix workflow input type check
ramonpetgrave64 b7e44ab
actionlint
ramonpetgrave64 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,117 @@ | ||
# Copyright 2023 SLSA Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
# A workflow to run against renovate-bot's PRs, | ||
# such as `make package` after it updates the package.json and package-lock.json files. | ||
|
||
# The potentially untrusted code is first run inside a low-privilege Job, and the diff is uploaded as an artifact. | ||
# Then a higher-privilege Job applies the diff and pushes the changes to the PR. | ||
# It's important to only run this workflow against PRs from trusted sources, after also reviewing the changes! | ||
|
||
# There have been vulnerabilities with using `git apply` https://github.blog/2023-04-25-git-security-vulnerabilities-announced-4/ | ||
# At this point a compromised git binary cannot modify any of this repo's branches, only the PR fork's branch, | ||
# due to our branch protection rules and CODEOWNERS. | ||
# It aslso cannot submit a new release or modify exsiting releases due to tag protection rules. | ||
|
||
name: Update actions dist post-commit | ||
|
||
permissions: {} | ||
|
||
on: | ||
workflow_dispatch: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I think we typically have 2 space indentation for the yaml files though it looks like the linter doesn't currently enforce it. |
||
inputs: | ||
pr_number: | ||
description: "The pull request number." | ||
required: true | ||
type: number | ||
|
||
jobs: | ||
diff: | ||
permissions: | ||
# This Job executes the PR's untrusted code, so it must how low permissions. | ||
pull-requests: read | ||
outputs: | ||
patch_not_empty: ${{ steps.diff.outputs.patch_not_empty }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
repository: ${{ github.repository }} | ||
persist-credentials: false | ||
- name: checkout-pr | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
PR_NUMBER: ${{ inputs.pr_number }} | ||
run: gh pr checkout "$PR_NUMBER" | ||
- name: run-command | ||
run: | | ||
find ./ -name "dist" -not -path "*/node_modules/*" -print0 \ | ||
| xargs -0 dirname \ | ||
| xargs -I {} sh -c '( | ||
echo "Updating {}" && \ | ||
cd {} && \ | ||
make clean \ | ||
&& make package | ||
)' | ||
|
||
- name: diff | ||
id: diff | ||
run: | | ||
git add . | ||
git status | ||
git diff HEAD > changes.patch | ||
[ -z "$(cat changes.patch)" ] && RESULT=false || RESULT=true | ||
echo "patch_not_empty=$RESULT" >> "$GITHUB_OUTPUT" | ||
- name: upload | ||
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 | ||
with: | ||
name: changes.patch | ||
path: changes.patch | ||
|
||
push: | ||
if: needs.diff.outputs.patch_not_empty == 'true' | ||
needs: diff | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# This Job does not run untrusted code, but it does need to push changes to the PR's branch. | ||
pull-requests: read | ||
contents: write | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: checkout-pr | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
PR_NUMBER: ${{ inputs.pr_number }} | ||
run: gh pr checkout "$PR_NUMBER" | ||
- name: download-patch | ||
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 | ||
with: | ||
name: changes.patch | ||
- id: apply | ||
run: | | ||
git apply changes.patch | ||
rm changes.patch | ||
# example from | ||
# https://github.com/actions/checkout/blob/cd7d8d697e10461458bc61a30d094dc601a8b017/README.md#push-a-commit-using-the-built-in-token | ||
- name: push | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add . | ||
git status | ||
git commit -s -m "update actions dist" | ||
git push |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. 1.7.0 has initial support for GitHub actions actions.yml and not just workflows.
https://github.com/rhysd/actionlint/releases/tag/v1.7.0