-
Notifications
You must be signed in to change notification settings - Fork 86
82 lines (74 loc) · 3.5 KB
/
broadcast-frontend-hash.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
76
77
78
79
80
81
82
name: Broadcast Frontend Hash
on:
workflow_dispatch:
inputs:
dfx_version:
description: 'Release version of dfx'
default: "latest"
# release:
# # https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads?actionType=released#release
# # "A release was published, or a pre-release was changed to a release."
# types: [released]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PLAYGROUND_REPO: ${{ github.repository_owner }}/motoko-playground
FILE: service/wasm-utils/whitelisted_wasms.txt
jobs:
update-frontend-hash:
runs-on: ubuntu-latest
steps:
- name: Install sponge
run: sudo apt-get install --yes moreutils
- name: Checkout dfinity/sdk repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # workaround to fetch all tags: https://github.com/actions/checkout/issues/701
path: sdk
- name: Get new hash
working-directory: ./sdk
env:
GH_TOKEN: ${{ github.token }}
run: |
git checkout ${{ inputs.dfx_version }}
echo "NEW_HASH=$(shasum -a 256 src/distributed/assetstorage.wasm.gz | cut -f1 -d" ")" >> $GITHUB_ENV
- name: Checkout dfinity/motoko-playground repo
uses: actions/checkout@v4
with:
token: ${{ secrets.NIV_UPDATER_TOKEN }}
repository: ${{ env.PLAYGROUND_REPO }}
path: motoko-playground
- name: Modify Rust file
working-directory: ./motoko-playground
run: |
# Below won't work on MacOS. If you want to debug it on MacOS, run:
# > sudo docker run -ti --rm ubuntu /bin/bash
# ubuntu> apt-get update && apt-get install --yes moreutils --fix-missing
head -n -1 ${{ env.FILE }} | sponge ${{ env.FILE }}
echo ' "${{ env.NEW_HASH }}", // dfx ${{ inputs.dfx_version }} frontend canister' >> ${{ env.FILE }}
echo ']' >> ${{ env.FILE }}
- name: Commit files, push changes, and create PR
env:
GH_TOKEN: ${{ secrets.NIV_UPDATER_TOKEN }}
working-directory: ./motoko-playground
run: |
git config author.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com"
git config author.name "${{ github.event.sender.login }}"
git config committer.email "41898282+github-actions[bot]@users.noreply.github.com"
git config committer.name "GitHub Actions Bot"
git config user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com"
git config user.name "${{ github.event.sender.login }}"
git checkout -b broadcast-frontend-hash-${{ inputs.dfx_version }}
git add ${{ env.FILE }}
git status
git commit -m "Update hash for dfx version ${{ inputs.dfx_version }}"
git push origin broadcast-frontend-hash-${{ inputs.dfx_version }}
echo "- new hash: ${{ env.NEW_HASH }}" >> pr.md
echo "- release: https://github.com/${{ github.repository_owner }}/sdk/releases/tag/${{ inputs.dfx_version }}" >> pr.md
gh pr create --title "chore: Whitelist frontend canister hash from dfx version ${{ inputs.dfx_version }}" \
--body-file pr.md \
--base main \
--head broadcast-frontend-hash-${{ inputs.dfx_version }} \
--repo ${{ env.PLAYGROUND_REPO }} \
--draft