Skip to content

chore(workflows): update github-actions (major) #28

chore(workflows): update github-actions (major)

chore(workflows): update github-actions (major) #28

Workflow file for this run

name: Build/Publish Docker Image
on:
push:
tags:
- v*
paths-ignore:
- 'k8s/**'
pull_request:
paths-ignore:
- 'k8s/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build-and-publish:
name: Build/Publish Docker Image
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Prepare
id: prep
run: |
PROJECT_VERSION=$(TZ=UTC git --no-pager log -n1 --date="format-local:%Y%m%dT%H%M%S" --pretty="format:%cd-%h" --abbrev=7)
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}
TAGS="$IMAGE:$VERSION,$IMAGE:$PROJECT_VERSION"
# outputs
for out in "build-date=$(date +%Y%m%d-%H:%M:%S)" "build-user=$(whoami)" "git-branch=$(git rev-parse --abbrev-ref HEAD)" "git-version=$(git rev-parse HEAD)" "version=${VERSION}" "tags=${TAGS}" "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')"; do
# echo "k=v" >> $GITHUB_OUTPUT
echo $out | tee >(cat) >> $GITHUB_OUTPUT
done
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v5
with:
allow: network.host
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
file: Dockerfile
context: .
build-args: |
BUILD_DATE=${{ steps.prep.outputs.build-date }}
BUILD_USER=${{ steps.prep.outputs.build-user }}
GIT_BRANCH=${{ steps.prep.outputs.git-branch }}
GIT_REVISION=${{ steps.prep.outputs.git-version }}
VERSION=${{ steps.prep.outputs.version }}