Skip to content

Image Build

Image Build #16

Workflow file for this run

name: Image Build
on: workflow_dispatch
env:
IMAGE_NAME: k1132-002
jobs:
auth-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
push:
needs: auth-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
- name: Build image
run: docker build . --file docker/app/Dockerfile --tag $IMAGE_NAME
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
COMMIT=$(echo "${{ github.sha }}")
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$COMMIT
docker push $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$COMMIT