Skip to content

merge 1.3.0 into main #6258

merge 1.3.0 into main

merge 1.3.0 into main #6258

Workflow file for this run

name: Publish Artifacts
on:
push:
branches:
- main
- develop
pull_request:
types: [opened, synchronize]
workflow_dispatch:
env:
PRIVATE_DOCKER_REGISTRY_URL: ${{ secrets.GITLAB_DOCKER_REGISTRY_URL }}
PRIVATE_DOCKER_REGISTRY_USER: Deploy-Token
PRIVATE_DOCKER_REGISTRY_PASS: ${{ secrets.GITLAB_PKG_REGISTRY_TOKEN }}
jobs:
publish:
permissions:
contents: read
packages: write
runs-on: [arc-runner-set]
if: |
"contains(github.event.head_commit.message, 'release-please--branches--main')" ||
${{ github.event_name == 'pull_request' }}
steps:
- name: ⬇️ Checkout
uses: actions/checkout@v3
with:
fetch-tags: true
- name: 🐳 Docker Login
uses: docker/login-action@v2
with:
registry: ${{ env.PRIVATE_DOCKER_REGISTRY_URL }}
username: ${{ env.PRIVATE_DOCKER_REGISTRY_USER }}
password: ${{ env.PRIVATE_DOCKER_REGISTRY_PASS }}
- name: Set extra environment and metadata
id: metadata
run: |
GIT_SHORT_COMMIT=$(git rev-parse --short "$GITHUB_SHA")
DOCKER_IMAGE_NAME=$(basename ${GITHUB_REPOSITORY})
echo "DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME}" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
if [ ${{github.event_name}} == "pull_request" ]
then
PR_NUMBER=$(echo $GITHUB_REF | awk -F/ '{ print $3 }')
ARTIFACT_VERSION=$(sed -n 's/.*\"version\": *\"\([^\"]*\)\".*/\1/p' package.json)-PR${PR_NUMBER}
echo "ARTIFACT_VERSION=${ARTIFACT_VERSION}" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
echo "DOCKER_COMMIT_TAG=${ARTIFACT_VERSION}-${GIT_SHORT_COMMIT}" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
echo "DOCKER_COMMIT_GHRUNID_TAG=${ARTIFACT_VERSION}-${GIT_SHORT_COMMIT}-${GITHUB_RUN_ID}" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
echo "DOCKER_LATEST_IMAGE_TAG=" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
else
ARTIFACT_VERSION="$(sed -n 's/.*\"version\": *\"\([^\"]*\)\".*/\1/p' package.json)"
echo "ARTIFACT_VERSION=${ARTIFACT_VERSION}" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
echo "DOCKER_COMMIT_TAG=${ARTIFACT_VERSION}-${GIT_SHORT_COMMIT}" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
echo "DOCKER_COMMIT_GHRUNID_TAG=${ARTIFACT_VERSION}-PR${PR_NUMBER}-${GIT_SHORT_COMMIT}-${GITHUB_RUN_ID}" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
BRANCH=${GITHUB_REF##*/}
echo "BRANCH=$BRANCH" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
# if tag for this is version is already there, skip docker build
docker manifest inspect ${{ env.PRIVATE_DOCKER_REGISTRY_URL }}/${DOCKER_IMAGE_NAME}:${CURRENT_VERSION} && echo "SKIP_DOCKER_PUSH=true" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
if [[ "${BRANCH}" == "develop" ]]
then
echo "ARTIFACT_VERSION=${CURRENT_VERSION}-develop" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
echo "DOCKER_LATEST_IMAGE_TAG=" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
else
echo "DOCKER_LATEST_IMAGE_TAG=${{ env.PRIVATE_DOCKER_REGISTRY_URL }}/${DOCKER_IMAGE_NAME}:latest" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
fi
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: 🔨 Build and Push docker image
uses: docker/build-push-action@v4
if: |
( steps.metadata.outputs.BRANCH == 'main' && steps.metadata.outputs.SKIP_DOCKER_PUSH != 'true' ) ||
github.event_name == 'pull_request'
with:
file: ./Dockerfile
context: .
push: true
tags: |
${{ env.DOCKER_LATEST_IMAGE_TAG }}
${{ env.PRIVATE_DOCKER_REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.ARTIFACT_VERSION }}
${{ env.PRIVATE_DOCKER_REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_COMMIT_TAG }}
${{ env.PRIVATE_DOCKER_REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_COMMIT_GHRUNID_TAG }}