runner-docker/.forgejo/workflows/package.yml
ItzYanick 671b4be8fb
All checks were successful
docker
More fixes
2023-03-24 13:34:44 +01:00

36 lines
1.3 KiB
YAML

name: package
on:
push:
tags:
- "v*.*.*"
jobs:
docker:
runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v2
- name: Log-in to Registry
run: echo "${{ secrets.PACKAGE_TOKEN }}" | docker login https://git.itzyanick.de -u ${{ github.actor }} --password-stdin
- name: Build and push container image
run: |
IMAGE_ID=$(echo git.itzyanick.de/${{ github.repository }} | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# when the branch is master, replace master with latest
[ "$VERSION" == "master" ] && VERSION=latest
CHECKOUT=$(echo "${{ github.ref }}" | sed 's|-.*||')
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
echo CHECKOUT=$CHECKOUT
# Build and Publish container image
docker buildx build --push \
--tag $IMAGE_ID:$VERSION \
--build-arg CHECKOUT=$CHECKOUT \
--platform linux/amd64 .