Build and Push HydroServer Docker Image to GHCR #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 Push HydroServer Docker Image to GHCR | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: 'Branch to build the Docker image from' | |
required: false | |
default: 'main' | |
tag_name: | |
description: 'Tag to apply to the Docker image' | |
required: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.release.tag_name || github.event.inputs.branch || 'main' }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Log in to GHCR | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: Dockerfile | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository }}:${{ github.event.release.tag_name || github.event.inputs.tag_name }} | |
ghcr.io/${{ github.repository }}:latest |