Skip to content

Migrate to native GHA concurrency configuration #29

Migrate to native GHA concurrency configuration

Migrate to native GHA concurrency configuration #29

name: Docker
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
IMAGE_NAME: wikijs-anyuid
jobs:
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Identify version to tag
run: |
echo "IMAGE_TAG=$(fgrep "FROM ghcr.io/requarks/wiki" Dockerfile | tail -1 | cut -d@ -f1 | rev | cut -d: -f1 | rev)" >> $GITHUB_ENV
- name: Build image
run: docker build . --file Dockerfile --tag "$IMAGE_NAME"
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: Push image
run: |
IMAGE_ID="ghcr.io/${{ github.repository }}/$IMAGE_NAME"
# Change all uppercase to lowercase
IMAGE_ID="$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')"
IMAGE_ID_VERSIONED="${IMAGE_ID}:${IMAGE_TAG}"
# Use Docker `latest` tag convention
echo IMAGE_ID="$IMAGE_ID"
echo IMAGE_ID_VERSIONED="$IMAGE_ID_VERSIONED"
docker tag "$IMAGE_NAME" "$IMAGE_ID_VERSIONED"
docker tag "$IMAGE_NAME" "$IMAGE_ID:latest"
docker push "$IMAGE_ID_VERSIONED"
docker push "$IMAGE_ID:latest"