SPUC-build-test-push #20
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: SPUC-build-test-push | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Push with versioned tag?' | |
required: false | |
type: string | |
default: '' | |
push: | |
branches: [ "main" ] | |
paths: | |
- 'code/SPUC/Dockerfile' | |
- '.github/workflows/spuc-build-test-push.yaml' | |
jobs: | |
build-push: | |
runs-on: ubuntu-latest | |
env: | |
CONTAINER_NAME: spuc | |
CONTEXT: ./code/SPUC | |
DOCKERFILE: ./code/SPUC/Dockerfile | |
README: ./code/SPUC/README.md | |
# -------------------------------------------------------------------------------- # | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to dockerhub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set tag | |
id: set-tag | |
run: | | |
IMAGE_REPO="${{ secrets.DOCKERHUB_USER }}/${{ env.CONTAINER_NAME }}" | |
if [ -z "${{ github.event.inputs.version }}" ]; then | |
echo "tags=${IMAGE_REPO}:latest" >> $GITHUB_OUTPUT | |
else | |
echo "tags=${IMAGE_REPO}:${{ github.event.inputs.version }},${IMAGE_REPO}:latest" >> $GITHUB_OUTPUT | |
fi | |
- name: Build and push to dockerhub | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ env.CONTEXT }} | |
file: ${{ env.DOCKERFILE }} | |
tags: ${{ steps.set-tag.outputs.tags }} | |
cache-from: type=gha,scope=${{ env.CONTAINER_NAME }} | |
cache-to: type=gha,scope=${{ env.CONTAINER_NAME }},mode=max | |
push: true | |
- name: Update description | |
uses: peter-evans/dockerhub-description@v4 | |
with: | |
username: ${{ secrets.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
repository: ${{ secrets.DOCKERHUB_USER }}/${{ env.CONTAINER_NAME }} | |
readme-filepath: ${{ env.README }} | |
enable-url-completion: true |