-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Release images on git tag (#23)
* feat: git tag * pr feedback * pr feedback * use schedule for docker metadata * remove tag event * pr feedback * fix: workflow name * fix: check if tag exists * pr feedback * pr feedback * pr feedback * feat: fail if git tag exists * update step name Co-authored-by: Jason Rasmussen <[email protected]> * pr feedback --------- Co-authored-by: Jason Rasmussen <[email protected]>
- Loading branch information
Showing
2 changed files
with
37 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,11 @@ name: Build and Push Docker Images | |
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
schedule: | ||
- cron: "0 11 * * 4" | ||
workflow_dispatch: | ||
inputs: | ||
pushDateTag: | ||
description: 'Push datestamp (production) tag' | ||
type: boolean | ||
required: false | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
|
@@ -62,16 +56,6 @@ jobs: | |
latest=false | ||
images: | | ||
name=ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}-${{ matrix.target }} | ||
tags: | | ||
# Tag scheduled runs with date | ||
type=schedule,pattern={{date 'YYYYMMDD'}} | ||
type=raw,value={{date 'YYYYMMDD'}},enable=${{ inputs.pushDateTag || false }} | ||
# Tag with branch name | ||
type=ref,event=branch | ||
# Tag with pr-number | ||
type=ref,event=pr | ||
# Tag with git tag on release | ||
type=ref,event=tag | ||
- name: Build and push image | ||
uses: docker/[email protected] | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Git tag | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 11 * * 4" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
set_tag: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: "main" | ||
fetch-depth: 0 | ||
token: ${{secrets.PAT}} | ||
|
||
- name: Create and push new tag | ||
run: | | ||
tag=$(date +'%Y%m%d') | ||
git config --global user.name 'GitHub Actions' | ||
git config --global user.email '[email protected]' | ||
if git tag -l $tag; then | ||
echo "Tag $tag already exists." | ||
exit 1 | ||
else | ||
git tag $tag | ||
git push origin $tag | ||
fi |