Skip to content

generate v1.0.1

generate v1.0.1 #112

name: Deploy Docker Image
on:
repository_dispatch:
types: [DOCKER]
workflow_dispatch:
push:
branches:
- main
- next
- next-major
- beta
- alpha
- '[0-9]*.[0-9x]*.x'
- oort
- '[0-9]*.[0-9x]*.x-oort'
release:
types: [published]
env:
IMAGE_NAME: oort_api
concurrency:
group: ${{ github.workflow }}-${{ github.event.client_payload.ref || github.ref }}
cancel-in-progress: true
jobs:
push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.client_payload.ref || github.ref }}
- name: Build image - ${{ github.event.client_payload.ref || github.ref }}
run: docker build . --target production --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image - ${{ github.event.client_payload.ref || github.ref }}
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.event.client_payload.ref || github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.event.client_payload.ref || github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION