Skip to content

Merge pull request #6 from OpenCHAMI/synackd/tempdir #28

Merge pull request #6 from OpenCHAMI/synackd/tempdir

Merge pull request #6 from OpenCHAMI/synackd/tempdir #28

Workflow file for this run

name: Build and Publish Docker Image
on:
push:
branches:
- main
paths:
- 'dockerfiles/dnf/Dockerfile'
tags:
- 'v*.*.*'
pull_request:
branches:
- main
paths:
- 'dockerfiles/dnf/Dockerfile'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from tag
if: startsWith(github.ref, 'refs/tags/')
id: extract_version
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Determine image tag
id: set_tag
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG="ghcr.io/openchami/image-build:v${GITHUB_REF#refs/tags/}"
elif [[ "${GITHUB_REF}" == refs/pull/* ]]; then
TAG="ghcr.io/openchami/image-build:latest-prbuild"
else
TAG="ghcr.io/openchami/image-build:test"
fi
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "Computed tag: ${TAG}"
- name: Build and push Docker image
# Only run this step if a valid tag is computed
if: steps.set_tag.outputs.tag != ''
uses: docker/build-push-action@v3
with:
context: .
file: dockerfiles/dnf/Dockerfile
push: true
tags: ${{ steps.set_tag.outputs.tag }}