-
Notifications
You must be signed in to change notification settings - Fork 4
80 lines (64 loc) · 2.4 KB
/
schedule.yml
File metadata and controls
80 lines (64 loc) · 2.4 KB
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
name: update-version
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Midnight - every night
jobs:
get_version:
runs-on: ubuntu-latest
name: Get next GITHUB_CLI_VERSION
# https://stackoverflow.com/a/61236803
outputs:
gh_version: ${{ steps.gh_version.outputs.gh_version }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ github.head_ref }}
- name: Get next gh version
id: gh_version
run: |
next_version="$(bash get-version.sh ${{ secrets.GITHUB_TOKEN }})"
echo "$next_version"
echo "gh_version=${next_version}" >> $GITHUB_OUTPUT
update:
runs-on: ubuntu-latest
name: Update GITHUB_CLI_VERSION
needs: get_version
if: ${{ needs.get_version.outputs.gh_version != '' }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ github.head_ref }}
- name: Write gh version to env
run: |
echo "gh_version=${{needs.get_version.outputs.gh_version}}" >> $GITHUB_ENV
- name: Update GITHUB_CLI_VERSION
run: |
echo "${{ env.gh_version }}" | grep -Pq "^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
find . -name Dockerfile -print0 | xargs -0 sed -i -E "s/^(ENV GITHUB_CLI_VERSION=).*$/\1${{ env.gh_version }}/g"
- name: Login to GitHub Container Registry
uses: docker/login-action@v4.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v7.1.0
id: "commit"
with:
commit_message: "Update GITHUB_CLI_VERSION to ${{ env.gh_version }}"
commit_user_name: actions-user
commit_user_email: actions@github.com
commit_author: GitHub Actions <actions@github.com>
- name: Push Docker Image
if: steps.commit.outputs.changes_detected == 'true'
uses: docker/build-push-action@v7.0.0
with:
push: true
context: .
file: ./debian/Dockerfile
tags: |
ghcr.io/${{ github.repository }}:${{ env.gh_version }}
ghcr.io/${{ github.repository }}:latest