-
Notifications
You must be signed in to change notification settings - Fork 64
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 #935 from ZeLonewolf/zlw-consolidate-workflow
Use GitHub App to post to checks tab
- Loading branch information
Showing
2 changed files
with
26 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,20 +42,6 @@ jobs: | |
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.16.1 #18.17.0 is buggy | ||
- name: Save PR number | ||
env: | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
PR_SHA: ${{ github.sha }} | ||
run: | | ||
mkdir -p ./pr | ||
echo $PR_NUMBER > ./pr/pr_number | ||
echo $PR_SHA > ./pr/pr_sha | ||
echo "Saved PR# ${{ github.event.pull_request.number }}, SHA# ${{ github.sha }} for upload" | ||
- name: Save PR# | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: pr_number | ||
path: pr/ | ||
- name: Install and Build 🔧 | ||
run: | | ||
npm ci --include=dev | ||
|
@@ -73,10 +59,10 @@ jobs: | |
- name: Compare Stats | ||
id: compare-stats | ||
run: | | ||
mkdir stats | ||
mkdir -p pr | ||
echo '${{ env.MAIN_STATS }}' | ||
echo '${{ env.PR_STATS }}' | ||
npm exec ts-node scripts/stats_compare '${{ env.MAIN_STATS }}' '${{ env.PR_STATS }}' > stats/stats-difference.md | ||
npm exec ts-node scripts/stats_compare '${{ env.MAIN_STATS }}' '${{ env.PR_STATS }}' > pr/stats-difference.md | ||
- name: Print Stats to GitHub Checks | ||
uses: LouisBrunner/[email protected] | ||
if: always() | ||
|
@@ -86,9 +72,22 @@ jobs: | |
conclusion: neutral | ||
output: | | ||
{"summary":"Style size changes introduced by this PR"} | ||
output_text_description_file: stats/stats-difference.md | ||
output_text_description_file: pr/stats-difference.md | ||
- name: Upload Build artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: americana | ||
path: dist/ | ||
- name: Save PR artifacts | ||
env: | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
PR_SHA: ${{ github.sha }} | ||
run: | | ||
echo $PR_NUMBER > pr/pr_number | ||
echo $PR_SHA > pr/pr_sha | ||
echo "Saved PR# ${{ github.event.pull_request.number }}, SHA# ${{ github.sha }} for upload" | ||
- name: Upload PR artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: pr_ci_artifacts | ||
path: pr/ |
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 |
---|---|---|
|
@@ -22,7 +22,7 @@ jobs: | |
run_id: context.payload.workflow_run.id, | ||
}); | ||
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { | ||
return artifact.name == "pr_number" | ||
return artifact.name == "pr_ci_artifacts" | ||
})[0]; | ||
let download = await github.rest.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
|
@@ -31,7 +31,7 @@ jobs: | |
archive_format: 'zip', | ||
}); | ||
let fs = require('fs'); | ||
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data)); | ||
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_ci_artifacts.zip`, Buffer.from(download.data)); | ||
- name: "Download Build" | ||
uses: actions/github-script@v6 | ||
with: | ||
|
@@ -54,7 +54,7 @@ jobs: | |
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/americana.zip`, Buffer.from(download.data)); | ||
- name: "Unzip artifacts" | ||
run: | | ||
unzip pr_number.zip | ||
unzip pr_ci_artifacts.zip | ||
unzip -d dist americana.zip | ||
- name: Set PR variable | ||
run: | | ||
|
@@ -110,12 +110,18 @@ jobs: | |
<img src="https://preview.ourmap.us/pr/${{ env.PR_NUM }}/sprites/sprite.png" /> | ||
<img src="https://preview.ourmap.us/pr/${{ env.PR_NUM }}/sprites/[email protected]" /> | ||
" > pr_preview.md | ||
- uses: tibdex/github-app-token@v1 | ||
# See https://josh-ops.com/posts/using-github-checks-api/ | ||
id: get_installation_token | ||
with: | ||
app_id: 396440 #osm-americana checks app | ||
private_key: ${{ secrets.CHECKS_WRITER_SECRET }} | ||
- name: Print Preview Links to GitHub Checks | ||
uses: LouisBrunner/[email protected] | ||
if: always() | ||
with: | ||
sha: ${{ env.PR_SHA }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
token: ${{ steps.get_installation_token.outputs.token }} | ||
name: PR Preview | ||
conclusion: neutral | ||
output: | | ||
|