-
-
Notifications
You must be signed in to change notification settings - Fork 30
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 #171 from carpentries/fix-pr-workflow
fix PR workflow
- Loading branch information
Showing
6 changed files
with
167 additions
and
81 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
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 |
---|---|---|
|
@@ -9,14 +9,6 @@ on: | |
- completed | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Print github context | ||
env: | ||
GITHUB_CONTEXT: ${{ toJSON(github) }} | ||
run: echo "$GITHUB_CONTEXT" | ||
|
||
# Pull requests are valid if: | ||
# - they match the sha of the workflow run head commit | ||
# - they are open | ||
|
@@ -31,34 +23,27 @@ jobs: | |
number: ${{ steps.get-pr.outputs.NUM }} | ||
steps: | ||
- name: 'Download PR artifact' | ||
id: dl | ||
uses: carpentries/actions/download-workflow-artifact@main | ||
with: | ||
run: ${{ github.event.workflow_run.id }} | ||
name: 'pr' | ||
|
||
- name: "Get PR Number" | ||
if: ${{ steps.dl.outputs.success == 'true' }} | ||
id: get-pr | ||
run: | | ||
unzip pr.zip | ||
echo "::set-output name=NUM::$(<./NR)" | ||
- name: "Check PR" | ||
id: check-pr | ||
if: ${{ steps.dl.outputs.success == 'true' }} | ||
uses: carpentries/actions/check-valid-pr@main | ||
with: | ||
pr: ${{ steps.get-pr.outputs.NUM }} | ||
sha: ${{ github.events.workflow_run.head_commit.sha }} | ||
|
||
show-outputs: | ||
name: "Show Outputs" | ||
runs-on: ubuntu-latest | ||
needs: test-pr | ||
steps: | ||
- run: | | ||
echo ${{ needs.test-pr.outputs.is_valid }} | ||
echo ${{ needs.test-pr.outputs.number }} | ||
echo ${{ needs.test-pr.outputs.payload }} | ||
# Create an orphan branch on this repository with two commits | ||
# - the current HEAD of the md-outputs branch | ||
# - the output from running the current HEAD of the pull request through | ||
|
@@ -79,14 +64,17 @@ jobs: | |
fetch-depth: 1 | ||
|
||
- name: 'Download built markdown' | ||
id: dl | ||
uses: carpentries/actions/download-workflow-artifact@main | ||
with: | ||
run: ${{ github.event.workflow_run.id }} | ||
name: 'built' | ||
|
||
- run: unzip built.zip | ||
- if: ${{ steps.dl.output.success == 'true' }} | ||
run: unzip built.zip | ||
|
||
- name: "Create orphan and push" | ||
if: ${{ steps.dl.output.success == 'true' }} | ||
run: | | ||
cd built/ | ||
git config --local user.email "[email protected]" | ||
|
@@ -113,15 +101,18 @@ jobs: | |
NR: ${{ needs.test-pr.outputs.number }} | ||
steps: | ||
- name: 'Download comment artifact' | ||
id: dl | ||
uses: carpentries/actions/download-workflow-artifact@main | ||
with: | ||
run: ${{ github.event.workflow_run.id }} | ||
name: 'diff' | ||
|
||
- run: unzip ${{ github.workspace }}/diff.zip | ||
- if: ${{ steps.dl.output.success == 'true' }} | ||
run: unzip ${{ github.workspace }}/diff.zip | ||
|
||
- name: "Comment on PR" | ||
id: comment-diff | ||
if: ${{ steps.dl.output.success == 'true' }} | ||
uses: carpentries/actions/comment-diff@main | ||
with: | ||
pr: ${{ env.NR }} | ||
|
@@ -130,10 +121,10 @@ jobs: | |
# Comment if the PR is open and matches the SHA, but the workflow files have | ||
# changed | ||
comment-changed-workflow: | ||
name: "Comment Changed Workflow" | ||
name: "Comment if workflow files have changed" | ||
needs: test-pr | ||
runs-on: ubuntu-latest | ||
if: ${{ needs.test-pr.outputs.is_valid != 'true' }} | ||
if: ${{ needs.test-pr.outputs.is_valid == 'false' }} | ||
env: | ||
NR: ${{ needs.test-pr.outputs.number }} | ||
steps: | ||
|
@@ -143,5 +134,8 @@ jobs: | |
uses: carpentries/actions/comment-diff@main | ||
with: | ||
pr: ${{ env.NR }} | ||
body: "Pull Request contains modified workflows; no preview will be created." | ||
body: | | ||
This pull request contains modified workflows and no preview will be created. | ||
**Please inspect the changes for any malicious content.** | ||
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.