Publish backend SNAPSHOT image #5
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: Publish backend SNAPSHOT image | |
on: | |
workflow_dispatch: | |
inputs: | |
cache_bust: | |
description: "Disable build cache" | |
required: false | |
type: boolean | |
push: | |
branches: | |
- dev | |
paths: | |
- "build/backend/**" | |
env: | |
BACKEND_IMAGE_NAME: sesp/openmrs-distro-sesp-backend | |
jobs: | |
build_push_backend: | |
name: Build and push backend SNAPSHOT image to C-Saúde Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ secrets.REGISTRY }} | |
username: ${{ secrets.REGISTRY_USERNAME }} | |
password: ${{ secrets.REGISTRY_PASSWORD }} | |
- name: Set VERSION environment variable | |
run: | | |
echo "VERSION=$(grep version build/backend/openmrs-distro.properties | cut -d'=' -f2)" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push backend | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
context: build/backend | |
secrets: | | |
GH_USERNAME=username | |
GH_PASSWORD=${{ secrets.GITHUB_TOKEN }} | |
tags: ${{ secrets.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:${{ env.VERSION }},${{ secrets.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:latest | |
cache-from: type=registry,ref=${{ secrets.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:cache | |
cache-to: type=registry,ref=${{ secrets.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:cache,image-manifest=true | |
no-cache: ${{ inputs.cache_bust || false}} |