This repository has been archived by the owner on Nov 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
96 lines (86 loc) · 3.2 KB
/
ipfs.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Ipfs uploader
# Uploads all changed md files to ipfs once merged to main
# Comments the pr
on:
pull_request:
push:
branches:
- main
permissions:
contents: write
jobs:
ipfs-upload:
runs-on: ubuntu-latest
name: Ipfs uploader
steps:
- name: Generate a token
id: generate_token
if: github.event_name != 'pull_request'
uses: actions/create-github-app-token@v1
with:
app_id: ${{ secrets.UPDATE_BOT_APP_ID }}
private_key: ${{ secrets.UPDATE_BOT_TOKEN }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.generate_token.outputs.token || github.token }}
persist-credentials: true
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
cache: "yarn"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Get all changed *.md file(s)
id: changed-files
uses: tj-actions/changed-files@f569b77fb1d9ad9f1a125757d7e9e07b1f320199
with:
json: true
write_output_files: true
files: |
src/**/*.md
- name: Run step if any *.md file(s) change
if: steps.changed-files.outputs.any_changed == 'true'
run: |
cat .github/outputs/all_changed_files.json
- name: replace main with hash
if: github.event_name != 'pull_request' && steps.changed-files.outputs.any_changed == 'true'
run: |
json_array=($(jq -r '.[]' ".github/outputs/all_changed_files.json"))
for i in "${json_array[@]}"
do
sed -i 's@https://github.com/bgd-labs/aave-proposals/blob/main/@https://github.com/bgd-labs/aave-proposals/blob/${{ github.sha }}/@g' $i
sed -i 's@https://github.com/bgd-labs/aave-proposals/tree/main/@https://github.com/bgd-labs/aave-proposals/blob/${{ github.sha }}/@g' $i
done
- name: Upload
if: steps.changed-files.outputs.any_changed == 'true'
env:
PINATA_KEY: ${{ secrets.PINATA_KEY }}
PINATA_SECRET: ${{ secrets.PINATA_SECRET }}
run: |
json_array=($(jq -r '.[]' ".github/outputs/all_changed_files.json"))
for i in "${json_array[@]}"
do
npx aave-cli ipfs $i -u ${{ github.event_name != 'pull_request'}}
done
- name: check diff and potentially commit
if: github.event_name != 'pull_request' && steps.changed-files.outputs.any_changed == 'true'
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
if [[ -z $(git status -s) ]]
then
echo "tree is clean"
else
git config --global user.name 'Cache bot'
git config --global user.email '[email protected]'
git config --global pull.rebase true
git stash
git pull origin ${{ github.event.repository.default_branch }}
git stash apply
git add src
git commit -am "fix(cache): automated cache update [skip ci]"
git push origin ${{ github.event.repository.default_branch }}
exit
fi