Skip to content

Docker Image Deployment #9

Docker Image Deployment

Docker Image Deployment #9

Workflow file for this run

name: Docker Image Deployment
on:
push:
tags: [ '*.*' ]
env:
DOCKER_IMAGE_NAME: "galera_cluster_healthcheck"
jobs:
security_scan:
uses: ./.github/workflows/security_scan.yml
build-and-publish-image:
needs: [security_scan]
name: Build and Publish Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
working-directory: ./app
run: |
current_version=$(echo ${{ github.ref_name }} | sed 's/\([0-9]*\.[0-9]*\).*$/\1/')
docker build -t $DOCKER_IMAGE_NAME:latest -t $DOCKER_IMAGE_NAME:$current_version .
- name: Login to GitHub Container Registry
run: echo ${{ secrets.TOKEN }} | docker login ghcr.io -u ${{ secrets.USERNAME }} --password-stdin
- name: Push Docker image to GitHub Container Registry
run: |
current_version=$(echo ${{ github.ref_name }} | sed 's/\([0-9]*\.[0-9]*\).*$/\1/')
docker tag $DOCKER_IMAGE_NAME:latest ghcr.io/${{ secrets.USERNAME }}/$DOCKER_IMAGE_NAME:latest
docker tag $DOCKER_IMAGE_NAME:$current_version ghcr.io/${{ secrets.USERNAME }}/$DOCKER_IMAGE_NAME:$current_version
docker push ghcr.io/${{ secrets.USERNAME }}/$DOCKER_IMAGE_NAME:latest
docker push ghcr.io/${{ secrets.USERNAME }}/$DOCKER_IMAGE_NAME:$current_version