-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33f63fc
commit a465bd3
Showing
4 changed files
with
44 additions
and
19 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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
name: Docker Image CI for GHCR | ||
'on': push | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build_and_publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Extract version from push command | ||
id: extract_version | ||
run: echo "::set-output name=version::$(echo ${GITHUB_REF#refs/tags/})" | ||
- name: Set up Docker | ||
run: docker login --username idabblewith --password ${{ secrets.GH_PAT }} ghcr.io | ||
|
||
- name: Check if version is provided | ||
id: check_version | ||
run: echo "::set-output name=version_provided::$(test -n "${{ steps.extract_version.outputs.version }}")" | ||
- name: Get the tag name | ||
id: tag | ||
run: echo "::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}" | ||
|
||
- name: Build and Push Image | ||
if: steps.check_version.outputs.version_provided == 'true' | ||
run: | | ||
docker login --username idabblewith --password ${{ secrets.GH_PAT }} ghcr.io | ||
docker buildx create --use | ||
docker buildx build . --tag ghcr.io/dbca-wa/science-projects-service:${{ steps.extract_version.outputs.version }} --push | ||
docker tag ghcr.io/dbca-wa/science-projects-service:${{ steps.extract_version.outputs.version }} ghcr.io/dbca-wa/science-projects-service:latest | ||
docker build . --tag ghcr.io/dbca-wa/science-projects-service:${{ steps.tag.outputs.TAG_NAME }} | ||
docker push ghcr.io/dbca-wa/science-projects-service:${{ steps.tag.outputs.TAG_NAME }} | ||
docker tag ghcr.io/dbca-wa/science-projects-service:${{ steps.tag.outputs.TAG_NAME }} ghcr.io/dbca-wa/science-projects-service:latest | ||
docker push ghcr.io/dbca-wa/science-projects-service:latest |
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
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