Skip to content
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

Use GitHub App to post to checks tab #935

Merged
merged 3 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions .github/workflows/build-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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/
14 changes: 10 additions & 4 deletions .github/workflows/s3-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand All @@ -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: |
Expand Down Expand Up @@ -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: |
Expand Down