Skip to content

deploy

deploy #142

Workflow file for this run

name: deploy
on:
workflow_dispatch:
inputs:
image_tag:
description: "Docker image tag to deploy"
required: true
default: "main"
environment:
description: "Environment to deploy too"
required: true
default: "sandbox"
type: choice
options:
- sandbox
- production
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Get GHCR package hash
id: get_package_hash
run: |
container_id=$(gh api --paginate -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /orgs/MinBZK/packages/container/amt/versions | jq -r '.[] | select(.metadata.container.tags | contains(["${{ inputs.image_tag }}"])) | .name')
echo "container_id=$container_id" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: check correct name
run: |
if [ -z "${{steps.get_package_hash.outputs.container_id}}" ]; then
echo "Variable is empty. Failing the workflow."
exit 1
fi
- uses: actions/checkout@v4
with:
repository: "minbzk/ai-validation-infra"
ref: main
token: ${{ secrets.GH_PAT }}
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Make changes to the file
run: |
sed -i 's/newTag: .*$/newTag: ${{inputs.image_tag }}@${{ steps.get_package_hash.outputs.container_id }}/g' apps/amt/overlays/${{ inputs.environment }}/kustomization.yaml
sed -i 's|minbzk.github.io/version: .*$|minbzk.github.io/version: ${{ inputs.image_tag }}|g' apps/amt/overlays/${{ inputs.environment }}/kustomization.yaml
git add apps/amt/overlays/${{ inputs.environment }}/kustomization.yaml
- name: show changes
run: git diff --staged
- name: push changes
run: |
git commit -m "Update amt overlay ${{ inputs.environment }} tag ${{ steps.get_package_hash.outputs.container_id }}"
git push --force-with-lease
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
notifyMattermost:
runs-on: ubuntu-latest
if: ${{ success() && inputs.environment == 'production' }}
steps:
- uses: mattermost/action-mattermost-notify@master
with:
MATTERMOST_WEBHOOK_URL: ${{ secrets.MM_WEBHOOK_RELEASES }}
TEXT: |
:sparkles: A new version of AMT has been released on production by ${{ github.triggering_actor }} :sparkles:.
It will be available within a few minutes on https://amt.prd.apps.digilab.network/.
MATTERMOST_USERNAME: ${{ github.triggering_actor }}