ci: fixes nightly release
This commit is contained in:
40
.github/workflows/nightly-release.yaml
vendored
40
.github/workflows/nightly-release.yaml
vendored
@@ -1,38 +1,40 @@
|
|||||||
name: Nightly Release
|
name: Nightly Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * *'
|
- cron: "0 0 * * *"
|
||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-date:
|
nightly-release:
|
||||||
name: Check dates
|
name: Nightly Build and Release Docker image (if code changed in 24h)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
|
||||||
should-run: ${{ steps.code-change.outputs.should-run }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
- name: Check if code has changed with 24 hours
|
|
||||||
continue-on-error: true
|
- name: Check if code has changed within 24 hours
|
||||||
id: code-change
|
id: code-change
|
||||||
run: |
|
run: |
|
||||||
[[ $(git rev-list --after="24 hours" --first-parent HEAD) ]] && echo "::set-output name=should-run::true"
|
if [[ $(git rev-list --after="24 hours" --first-parent HEAD) ]]; then
|
||||||
build-release:
|
echo "should-run=true" >> $GITHUB_OUTPUT
|
||||||
name: Build and release Docker image
|
else
|
||||||
runs-on: ubuntu-latest
|
echo "should-run=false" >> $GITHUB_OUTPUT
|
||||||
needs: check-date
|
fi
|
||||||
if: needs.check-date.outputs.should-run == 'true'
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Login into GitHub Container Registry
|
- name: Login into GitHub Container Registry
|
||||||
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
|
if: steps.code-change.outputs.should-run == 'true'
|
||||||
|
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
|
||||||
|
|
||||||
- name: Build Docker image
|
- name: Build Docker image
|
||||||
|
if: steps.code-change.outputs.should-run == 'true'
|
||||||
run: |
|
run: |
|
||||||
docker build \
|
docker build \
|
||||||
-t "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA:0:7}" \
|
-t "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA:0:7}" \
|
||||||
-t "ghcr.io/${GITHUB_REPOSITORY}:nightly" .
|
-t "ghcr.io/${GITHUB_REPOSITORY}:nightly" .
|
||||||
|
|
||||||
- name: Release Docker image
|
- name: Release Docker image
|
||||||
|
if: steps.code-change.outputs.should-run == 'true'
|
||||||
run: |
|
run: |
|
||||||
docker push "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA:0:7}"
|
docker push "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA:0:7}"
|
||||||
docker push "ghcr.io/${GITHUB_REPOSITORY}:nightly"
|
docker push "ghcr.io/${GITHUB_REPOSITORY}:nightly
|
||||||
|
|||||||
Reference in New Issue
Block a user