-
Notifications
You must be signed in to change notification settings - Fork 19
49 lines (48 loc) · 1.6 KB
/
update-indexes.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
name: Update Indexes
on:
workflow_dispatch:
schedule:
- cron: '0 */12 * * *'
jobs:
update-indicadores:
name: Update indicadores
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
check-latest: true
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable --immutable-cache --check-cache
- name: Update indicadores.json
run: yarn update-indexes
- name: Checking for changes
id: check_changes
run: |
if git diff --exit-code assets/indicadores.json; then
echo "has_changes=false" >> $GITHUB_ENV
else
echo "has_changes=true" >> $GITHUB_ENV
fi
- name: Commit and push changes
if: ${{ env.has_changes == 'true' }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add assets/indicadores.json
git commit -m "Update indicadores.json on $(date -u +"%Y-%m-%dT%H:%M:%SZ")"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger publish workflow
if: ${{ env.has_changes == 'true' }}
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/publish.yml/dispatches \
-d '{"ref":"master"}'