From 671b4be8fbe4d21d66d47021259e5a6126c313d3 Mon Sep 17 00:00:00 2001 From: ItzYanick Date: Fri, 24 Mar 2023 13:34:44 +0100 Subject: [PATCH] More fixes --- .forgejo/workflows/package.yml | 37 ++++++++++++++++++++-------------- Dockerfile | 2 +- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.forgejo/workflows/package.yml b/.forgejo/workflows/package.yml index be64983..cdd8682 100644 --- a/.forgejo/workflows/package.yml +++ b/.forgejo/workflows/package.yml @@ -12,18 +12,25 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Login to Docker Registry - uses: https://github.com/docker/login-action@v2 - with: - registry: git.itzyanick.de - username: ItzYanick - password: ${{ secrets.PACKAGE_TOKEN }} - - name: Build and push - uses: https://github.com/docker/build-push-action@v4 - with: - context: . - file: ./Dockerfile - push: true - tags: git.itzyanick.de/itzyanick/runner-docker:latest - build-args: | - CHECKOUT=${{ github.ref }} + - 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 . diff --git a/Dockerfile b/Dockerfile index e4a2c16..e39cfaa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN apk fix && \ apk --no-cache --update add git make RUN mkdir /build -RUN git clone https://git.itzyanick.de/ItzYanick/runner-docker.git /build/runner \ +RUN git clone https://code.forgejo.org/forgejo/runner.git /build/runner \ && cd /build/runner \ && git checkout $CHECKOUT