-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (48 loc) · 1.59 KB
/
update.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
name: Update
on:
schedule:
- cron: '40 18 19 * *'
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
env:
BASE_BRANCH: "main"
HEAD_BRANCH: "github-actions-update"
TZOT_PATH: "tzot.json"
steps:
- uses: actions/checkout@v4
- name: Initialize branch
run: |
set -eux
git config --global user.name 'GitHub Actions Update'
git config --global user.email '[email protected]'
git fetch
git checkout "${BASE_BRANCH}"
git push origin --delete "${HEAD_BRANCH}" || true
git checkout -b "${HEAD_BRANCH}"
- name: Update ${{ env.TZOT_PATH }}
run: |
set -eux
docker compose up --build update
if [ -n "$(git diff)" ]; then
echo "NEW_VERSION_FOUND=true" >> "${GITHUB_ENV}"
echo "TZ_VERSION=$(cat gen/version)" >> "${GITHUB_ENV}"
fi
- name: Commit and push
if: ${{ env.NEW_VERSION_FOUND == 'true' }}
run: |
set -eux
git commit -am "Update $TZOT_PATH ($TZ_VERSION)"
git push --set-upstream origin "${HEAD_BRANCH}"
- name: Create PR
if: ${{ env.NEW_VERSION_FOUND == 'true' }}
env:
GH_TOKEN: ${{ github.token }}
run: |
set -eux
gh pr create \
--base "${BASE_BRANCH}" \
--head "${HEAD_BRANCH}" \
--title "Update $TZOT_PATH ($TZ_VERSION)" \
--body "GitHub Actions Run URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"