-
Notifications
You must be signed in to change notification settings - Fork 8
75 lines (69 loc) · 2.39 KB
/
upload.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Upload
on:
workflow_run:
workflows: [Rust]
types:
- completed
permissions:
checks: write
contents: read
pull-requests: write
jobs:
upload:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
env:
PAPERAGE_PASSPHRASE: supersecret
steps:
- uses: actions/checkout@v3
- name: 'Download artifact'
uses: actions/github-script@v6
with:
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
name: "visual-snapshots"
});
var matchArtifact = artifacts.data.artifacts[0];
var download = await github.rest.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}}/visual-snapshots.zip', Buffer.from(download.data));
- name: Create directory
run: mkdir -p visual-snapshots
- name: Unzip artifact
run: unzip visual-snapshots.zip -d ./visual-snapshots
- name: Display structure of downloaded files
run: ls -R visual-snapshots/
- name: Set variables
run: |
PR_NUMBER=$(cat ./visual-snapshots/PR.txt)
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
- name: Upload to B2
uses: shallwefootball/s3-upload-action@master
id: B2
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: ${{ vars.AWS_BUCKET }}
endpoint: ${{ vars.AWS_ENDPOINT }}
source_dir: "visual-snapshots"
destination_dir: "30-days/${{ github.repository }}/${{ github.run_id }}"
- name: Generate snapshots comment
run: ./bin/snapshots-comment '${{steps.B2.outputs.object_locations}}'
- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ env.PR_NUMBER != '' }}
with:
number: ${{ env.PR_NUMBER }}
header: "Visual Snapshots"
path: "./visual-snapshots.tmp"
- name: Job summary (visuals)
run: cat visual-snapshots.tmp > $GITHUB_STEP_SUMMARY