Skip to content

Build and publish a Docker image to ghcr.io #3

Build and publish a Docker image to ghcr.io

Build and publish a Docker image to ghcr.io #3

name: Build and publish a Docker image to ghcr.io
on:
workflow_dispatch:
inputs:
SERVICE_NAME:
required: true
type: string
description: "service name to release: gorya-backend || gorya-ui"
IMAGE_TAG:
required: true
type: string
description: "tag for container image"
jobs:
backend_image_publish:
runs-on: "ubuntu-20.04"
if: ${{ inputs.SERVICE_NAME == 'gorya-backend' }}
env:
SERVICE_NAME: ${{ inputs.SERVICE_NAME }}
IMAGE_TAG: ${{ inputs.IMAGE_TAG }}
steps:
- uses: actions/checkout@v2
- name: 'Checkout GitHub Action'
uses: actions/checkout@main
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GH_PAT}}
- name: 'Build Backend Image'
run: |
docker build --build-arg VERSION=${{ env.IMAGE_TAG }} --build-arg GIT_COMMIT=${{ github.sha }} --build-arg GIT_TREE_STATE=clean -f backend.Dockerfile . --tag ghcr.io/${{github.actor}}/gorya-backend:${{ env.IMAGE_TAG }}
docker push ghcr.io/${{github.actor}}/gorya-backend:${{ env.IMAGE_TAG }}
ui_image_publish:
runs-on: "ubuntu-20.04"
if: ${{ inputs.SERVICE_NAME == 'gorya-ui' }}
env:
SERVICE_NAME: ${{ inputs.SERVICE_NAME }}
IMAGE_TAG: ${{ inputs.IMAGE_TAG }}
steps:
- uses: actions/checkout@v2
- name: 'Checkout GitHub Action'
uses: actions/checkout@main
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GH_PAT}}
- name: 'Build UI Image'
run: |
docker build -f frontend.Dockerfile . --tag ghcr.io/${{github.actor}}/gorya-ui:${{ env.IMAGE_TAG }}
docker push ghcr.io/${{github.actor}}/gorya-ui:${{ env.IMAGE_TAG }}