Trigger Release #319
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Trigger Release | |
on: | |
push: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
build: | |
if: ${{ ! startsWith(github.ref, 'refs/tags/') }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set IMAGE | |
run: echo "IMAGE=${GITHUB_REPOSITORY#*/docker-}" >> "${GITHUB_ENV}" | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set VERSION | |
if: github.ref == 'refs/heads/main' | |
run: | | |
# shellcheck disable=SC2086 | |
VERSION="$(\grep ${IMAGE}/Dockerfile -e '^FROM' | \head -n 1 | \sed -e 's/@.*$//; s/^.*://;')" | |
if [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then | |
\echo "VERSION=${VERSION}" >> "${GITHUB_ENV}" | |
fi | |
- name: Check if release already exists | |
if: env.VERSION != '' | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
id: check-release | |
with: | |
script: | | |
const { VERSION } = process.env | |
return github.rest.repos.getReleaseByTag({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag: `v${VERSION}`, | |
}).then(function(result) { | |
core.debug(JSON.stringify(result)) | |
core.info(`Release ${result.data.tag_name} found`) | |
return result.data.tag_name | |
}).catch(function(error) { | |
if (error.status === 404) { | |
core.info(`Release v${VERSION} not found`) | |
return | |
} else { | |
throw error | |
} | |
}) | |
result-encoding: string | |
- name: Trigger Release | |
if: env.VERSION != '' && steps.check-release.outputs.result == 'undefined' | |
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4 | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
with: | |
tag_name: v${{ env.VERSION }} |