Skip to content

Commit

Permalink
Suite tagging (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
mo-c4t authored Sep 18, 2023
1 parent d00ba25 commit ee024a5
Showing 1 changed file with 34 additions and 26 deletions.
60 changes: 34 additions & 26 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:
- dev
- suite
- suite-c4t
tags:
- v*

env:
node_version: 16
Expand All @@ -33,69 +35,75 @@ jobs:
run: |
DOCKER_IMAGE_NAME="europe-west3-docker.pkg.dev/pwk-c4t-dev/internal-camino-dev/camino-suite"
echo "create_tag=false" >> $GITHUB_OUTPUT
if [[ "${{ github.ref }}" == "refs/heads/c4t" ]]; then
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "docker_image=$DOCKER_IMAGE_NAME:stage" >> $GITHUB_OUTPUT
echo "build_env=stage" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == "refs/heads/suite-c4t" ]]; then
echo "branch=suite-c4t" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == "refs/heads/c4t" ]] || [[ "${{ github.base_ref }}" == "c4t" ]]; then
echo "docker_image=$DOCKER_IMAGE_NAME:stage" >> $GITHUB_OUTPUT
echo "build_env=stage" >> $GITHUB_OUTPUT
echo "branch=c4t" >> $GITHUB_OUTPUT
CURRENT_TAG=$(git describe --abbrev=0 --tags)
if [[ $CURRENT_TAG == *"-rc"* ]]; then
TAG_TEMP=$(echo "$CURRENT_TAG"|awk -F'-rc' -v OFS='-rc' '{$2=sprintf("%1d",++$2)}7')
echo "tag=$TAG_TEMP" >> $GITHUB_OUTPUT
echo "create_tag=true" >> $GITHUB_OUTPUT
fi
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
elif [[ "${{ github.ref }}" == "refs/heads/suite-c4t" ]] || [[ "${{ github.base_ref }}" == "suite-c4t" ]]; then
echo "docker_image=$DOCKER_IMAGE_NAME:stage" >> $GITHUB_OUTPUT
echo "build_env=stage" >> $GITHUB_OUTPUT
echo "branch=suite-c4t" >> $GITHUB_OUTPUT
CURRENT_TAG=$(git describe --abbrev=0 --tags)
if [[ $CURRENT_TAG == *"-rc"* ]]; then
TAG_TEMP=$(echo "$CURRENT_TAG"|awk -F'-rc' -v OFS='-rc' '{$2=sprintf("%1d",++$2)}7')
echo "tag=$TAG_TEMP" >> $GITHUB_OUTPUT
echo "create_tag=true" >> $GITHUB_OUTPUT
fi
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]] || [[ "${{ github.base_ref }}" == "dev" ]]; then
echo "docker_image=$DOCKER_IMAGE_NAME:dev" >> $GITHUB_OUTPUT
echo "build_env=dev" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == "refs/heads/suite" ]]; then
echo "branch=dev" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == "refs/heads/suite" ]] || [[ "${{ github.base_ref }}" == "suite" ]]; then
echo "docker_image=$DOCKER_IMAGE_NAME:dev" >> $GITHUB_OUTPUT
echo "build_env=dev" >> $GITHUB_OUTPUT
echo "branch=suite" >> $GITHUB_OUTPUT
else
echo "docker_image=$DOCKER_IMAGE_NAME:temp" >> $GITHUB_OUTPUT
echo "branch=temp" >> $GITHUB_OUTPUT
echo "build_env=dev" >> $GITHUB_OUTPUT
fi
- name: Create tag
if: ${{ (github.ref == 'refs/heads/suite-c4t') && (github.event_name == 'push') && (steps.setDefaults.outputs.create_tag == 'true') }}
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.setDefaults.outputs.tag }}',
sha: context.sha
})
- name: Cloud authentication
if: github.event_name == 'push'
id: auth
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'

- name: Create tag
if: ${{ (github.ref == 'refs/heads/suite-c4t') && (github.event_name == 'push') && (steps.setDefaults.outputs.create_tag == 'true') }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git tag -a ${{ steps.setDefaults.outputs.tag }} -m "create tag ${{ steps.setDefaults.outputs.tag }} for staging"
git push --tags
- name: create module docker image
if: github.event_name == 'push'
if: ${{ (github.event_name == 'push') }}
run: |
gcloud auth configure-docker --quiet europe-west3-docker.pkg.dev
docker build . -t ${{ env.module_docker_image }}:${{ github.ref_name }} --build-arg BUILD_ENV=build:${{ steps.setDefaults.outputs.build_env }}
docker push ${{ env.module_docker_image }}:${{ github.ref_name }}
docker build . -t ${{ env.module_docker_image }}:${{ steps.setDefaults.outputs.branch }} --build-arg BUILD_ENV=build:${{ steps.setDefaults.outputs.build_env }}
docker push ${{ env.module_docker_image }}:${{ steps.setDefaults.outputs.branch }}
- name: create suite docker image
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
docker build . -f Dockerfile_SUITE -t ${{ steps.setDefaults.outputs.docker_image }} --build-arg BUILD_ENV=build:${{ steps.setDefaults.outputs.build_env }} --build-arg EXPLORER_BRANCH=${{ github.base_ref }} --build-arg WALLET_BRANCH=${{ github.base_ref }}
else
docker build . -f Dockerfile_SUITE -t ${{ steps.setDefaults.outputs.docker_image }} --build-arg BUILD_ENV=build:${{ steps.setDefaults.outputs.build_env }} --build-arg EXPLORER_BRANCH=${{ github.ref_name }} --build-arg WALLET_BRANCH=${{ github.ref_name }}
fi
docker build . -f Dockerfile_SUITE -t ${{ steps.setDefaults.outputs.docker_image }} --build-arg BUILD_ENV=build:${{ steps.setDefaults.outputs.build_env }} --build-arg EXPLORER_BRANCH=${{ steps.setDefaults.outputs.branch }} --build-arg WALLET_BRANCH=${{ steps.setDefaults.outputs.branch }}
- name: push and deploy docker
if: github.event_name == 'push'
if: ${{ (github.event_name == 'push') }}
run: |
gcloud auth configure-docker --quiet europe-west3-docker.pkg.dev
docker push ${{ steps.setDefaults.outputs.docker_image }}
Expand Down

0 comments on commit ee024a5

Please sign in to comment.