-
Notifications
You must be signed in to change notification settings - Fork 3
38 lines (34 loc) · 1.22 KB
/
refresh-channels.yaml
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
name: Refresh Channels
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
env:
REFRESH_BRANCH: gha-automated-refresh
jobs:
refresh-channels:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: 'main'
fetch-depth: 0
- name: Run refresh script
run: ./refresh_channels.sh
- name: Open or refresh PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action Runner"
git switch --force-create "${{ env.REFRESH_BRANCH }}" origin/main
git add .
if git diff-index --quiet HEAD; then
echo "No new updates. Nothing to do."
exit 0
fi
message="Automatic update. Run ID ${{ github.run_id }}, Number ${{ github.run_number}}, Attempt ${{ github.run_attempt }}"
git commit -m "${message}"
git push --force origin "${{ env.REFRESH_BRANCH }}"
gh pr create --fill --head "${{ env.REFRESH_BRANCH }}" || gh pr edit --base "${{ env.REFRESH_BRANCH }}" --title "${message}"