|
1 | 1 | name: Nightly Release
|
| 2 | + |
2 | 3 | on:
|
3 | 4 | schedule:
|
4 |
| - - cron: '0 0 * * *' |
| 5 | + - cron: "0 0 * * *" |
5 | 6 | workflow_dispatch: {}
|
| 7 | + |
6 | 8 | jobs:
|
7 |
| - check-date: |
8 |
| - name: Check dates |
| 9 | + nightly-release: |
| 10 | + name: Nightly Build and Release Docker image (if code changed in 24h) |
9 | 11 | runs-on: ubuntu-latest
|
10 |
| - outputs: |
11 |
| - should-run: ${{ steps.code-change.outputs.should-run }} |
12 | 12 | steps:
|
13 | 13 | - name: Checkout repository
|
14 |
| - uses: actions/checkout@v2 |
15 |
| - - name: Check if code has changed with 24 hours |
16 |
| - continue-on-error: true |
| 14 | + uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Check if code has changed within 24 hours |
17 | 17 | id: code-change
|
18 | 18 | run: |
|
19 |
| - [[ $(git rev-list --after="24 hours" --first-parent HEAD) ]] && echo "::set-output name=should-run::true" |
20 |
| - build-release: |
21 |
| - name: Build and release Docker image |
22 |
| - runs-on: ubuntu-latest |
23 |
| - needs: check-date |
24 |
| - if: needs.check-date.outputs.should-run == 'true' |
25 |
| - steps: |
26 |
| - - name: Checkout repository |
27 |
| - uses: actions/checkout@v2 |
| 19 | + if [[ $(git rev-list --after="24 hours" --first-parent HEAD) ]]; then |
| 20 | + echo "should-run=true" >> $GITHUB_OUTPUT |
| 21 | + else |
| 22 | + echo "should-run=false" >> $GITHUB_OUTPUT |
| 23 | + fi |
| 24 | +
|
28 | 25 | - name: Login into GitHub Container Registry
|
29 |
| - run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin |
| 26 | + if: steps.code-change.outputs.should-run == 'true' |
| 27 | + run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin |
| 28 | + |
30 | 29 | - name: Build Docker image
|
| 30 | + if: steps.code-change.outputs.should-run == 'true' |
31 | 31 | run: |
|
32 | 32 | docker build \
|
33 | 33 | -t "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA:0:7}" \
|
34 | 34 | -t "ghcr.io/${GITHUB_REPOSITORY}:nightly" .
|
| 35 | +
|
35 | 36 | - name: Release Docker image
|
| 37 | + if: steps.code-change.outputs.should-run == 'true' |
36 | 38 | run: |
|
37 | 39 | docker push "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA:0:7}"
|
38 |
| - docker push "ghcr.io/${GITHUB_REPOSITORY}:nightly" |
| 40 | + docker push "ghcr.io/${GITHUB_REPOSITORY}:nightly |
0 commit comments