v1.0.0-dev.5 #4
Workflow file for this run
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
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images | |
# https://docs.docker.com/build/ci/github-actions/manage-tags-labels/ | |
name: Publish Docker Image Workflow | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: {} | |
jobs: | |
publish-docker: | |
if: github.event.pull_request.draft == false | |
runs-on: ubuntu-latest | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
permissions: | |
contents: read | |
packages: write | |
name: Publish Docker Job | |
steps: | |
- name: Checkout latest code | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | |
# - name: Setup CI environment | |
# uses: ./.github/actions/ci-setup | |
# # build and deploy | |
# - name: Build project | |
# run: ./gradlew war | |
# prepare tags | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
ghcr.io/gipo999/webapp-boilerplate | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=schedule | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
## DOCKER BUILD AND PUSH to GHCR | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
if: github.event_name != 'pull_request' | |
with: | |
registry: ghcr.io | |
username: ${{github.actor}} | |
password: ${{secrets.GITHUB_TOKEN}} | |
# - name: Login to Docker Hub | |
# if: github.event_name != 'pull_request' | |
# uses: docker/login-action@v3 | |
# with: | |
# username: ${{ secrets.DOCKERHUB_USERNAME }} | |
# password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# TODO: remove context dump | |
- name: dump context for debugging | |
run: echo "$GITHUB_CONTEXT" | |
shell: bash | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
- name: set version as env var | |
shell: bash | |
run: | | |
NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3 | cut -d "v" -f2-) # 1.0.0-dev.1 | |
echo "New version: ${NEW_VERSION}" | |
echo "Github username: ${GITHUB_ACTOR}" | |
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64 | |
push: ${{ github.event_name != 'pull_request' }} | |
# tags: ghcr.io/${{ github.repository_owner }}/its-battistar-express:latest | |
# TODO: tag with release version | |
tags: ${{ steps.meta.outputs.tags }}, ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest | |
labels: ${{ steps.meta.outputs.labels }} |