-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split dep checker into pull_request and workflow_run since
pull_request_target did not work the way I thought, and also is a potential security risk (see https://securitylab.github.com/research/github-actions-preventing-pwn-requests for details)
- Loading branch information
Showing
4 changed files
with
121 additions
and
26 deletions.
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,84 @@ | ||
name: Dependency Tree Reporter | ||
# This gets called when ./dep-diff-pull_request.yml has completed. See that file | ||
# for why this is split into two. | ||
on: | ||
workflow_run: | ||
workflows: [ "Dependency Tree Input Builder" ] | ||
types: | ||
- completed | ||
env: | ||
# The name of the labels to use if the dependencies are ok | ||
DEPS_OK_LABEL_NAME: deps-ok | ||
# The name of the labels to use if the dependencies changed | ||
DEPS_CHANGED_LABEL_NAME: deps-changed | ||
# People/teams to mention in the PR comment if dependencies changed | ||
CHANGE_MENTIONS: '@wildfly/prod' | ||
jobs: | ||
compare: | ||
runs-on: ubuntu-latest | ||
if: > | ||
${{ github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- name: Download artifacts | ||
# It would have been nice to be able to use actions/download-artifact@v2 | ||
# for this, but as the artifacts are uploaded by another workflow it does | ||
# not seem possible - so we need to do this stuff instead | ||
uses: actions/[email protected] | ||
with: | ||
script: | | ||
var artifacts = await github.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: ${{github.event.workflow_run.id }}, | ||
}); | ||
console.log(artifacts); | ||
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | ||
return artifact.name == "input-artifacts" | ||
})[0]; | ||
var download = await github.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: matchArtifact.id, | ||
archive_format: 'zip', | ||
}); | ||
var fs = require('fs'); | ||
fs.writeFileSync('${{github.workspace}}/input.zip', Buffer.from(download.data)); | ||
- name: Set needed env vars in outputs | ||
id: prepare | ||
run: | | ||
unzip input.zip | ||
echo current directory contents | ||
ls -al | ||
echo "::set-output name=deps_ok_label_name::${DEPS_OK_LABEL_NAME}" | ||
echo "::set-output name=deps_changed_label_name::${DEPS_CHANGED_LABEL_NAME}" | ||
echo "::set-output name=change_mentions::${CHANGE_MENTIONS}" | ||
echo Reading PR number | ||
tmp=$(<pr) | ||
echo "PR: ${tmp}" | ||
echo Reading base version files | ||
tmp=$(<baseVersions) | ||
echo "Base version files: ${tmp}" | ||
echo "::set-output name=base_files::${tmp}" | ||
echo Reading new version files | ||
tmp=$(<newVersions) | ||
echo "New version files: ${tmp}" | ||
echo "::set-output name=new_files::${tmp}" | ||
# - name: Setup tmate session | ||
# uses: mxschmitt/action-tmate@v3 | ||
|
||
- name: Check versions | ||
uses: wildfly/dep-tree-diff@master | ||
with: | ||
token: '${{ secrets.GITHUB_TOKEN }}' | ||
deps-ok-label: ${{ steps.prepare.outputs.deps_ok_label_name }} | ||
deps-changed-label: ${{ steps.prepare.outputs.deps_changed_label_name }} | ||
tool-change-mentions: ${{ steps.prepare.outputs.change_mentions }} | ||
base-version-files: ${{ steps.prepare.outputs.base_files }} | ||
new-version-files: ${{ steps.prepare.outputs.new_files }} |
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,2 @@ | ||
yyyy | ||
xxx |