Build and Publish Docker Image #8
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: Build and Publich Docker Image | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: The image version | |
required: true | |
type: string | |
env: | |
IMAGE_NAME: befit | |
REGISTRY_URL: ghcr.io | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: install buildx | |
uses: crazy-max/ghaction-docker-buildx@v3 | |
- name: Build the Docker image | |
run: docker buildx build --push --platform linux/arm64/v8,linux/amd64 --file Dockerfile --tag $REGISTRY_URL/${{ github.actor }}/$IMAGE_NAME:${{ inputs.version }} . | |
working-directory: backend | |
- name: Login to Container Registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login $REGISTRY_URL -u ${{ github.actor }} --password-stdin | |
- run: docker images | |
- name: Publish the Docker image | |
run: docker push $REGISTRY_URL/${{ github.actor }}/$IMAGE_NAME:${{ inputs.version }} |