Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deployment #37

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
branches:
- 'main'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
REGISTRY: ghcr.io
POETRY_CACHE_DIR: ~/.cache/pypoetry
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: deploy


on:
push:
branches:
- main
workflow_dispatch:
inputs:
image_tag:
description: 'Docker image tag to deploy'
required: true
default: 'main'
environment:
description: 'Environment to deploy to'
required: true
default: 'stag'
options:
- stag
- prod

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: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /orgs/MinBZK/packages/container/tad/versions | jq '.[] | select(.metadata.container.tags | contains(["${{ inputs.image_tag }}"])) | .name' >> "$GITHUB_OUTPUT"
else
gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /orgs/MinBZK/packages/container/tad/versions | jq '.[] | select(.metadata.container.tags | contains(["main"])) | .name' >> "$GITHUB_OUTPUT"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get deploy environment
id: get_deploy_env
run: |
laurensWe marked this conversation as resolved.
Show resolved Hide resolved
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
if [ "${{ inputs.environment }}" == "prod" ]; then
echo "production" >> "$GITHUB_OUTPUT"
else
echo "staging" >> "$GITHUB_OUTPUT"
fi
echo "" >> "$GITHUB_OUTPUT"
else
echo "staging" >> "$GITHUB_OUTPUT"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: check correct name
run: |
if [ -z "${{steps.get_package_hash.outputs}}" ]; then
echo "Variable is empty. Failing the workflow."
exit 1
fi

- name: Print deploy hash and environment
laurensWe marked this conversation as resolved.
Show resolved Hide resolved
run: |
echo ${{ steps.get_package_hash.outputs }}
echo ${{ steps.get_deploy_env.outputs }}

- uses: actions/checkout@v4
with:
repository: '${{ github.server_url }}/minbzk/ai-validation-infra'
ssh-key: ${{ secrets.DEPLOY_KEY }}
ref: main
path: ai-validation-infra

- name: Make changes to the file
run: |
cd ai-validation-infra
sed -i 's/newTag: .*$/newTag: ${{ steps.get_package_hash.outputs }}/g' apps/tad/overlays/${{ steps.get_deploy_env.outputs }}/kustomization.yaml
git add apps/tad/overlays/${{ steps.get_deploy_env.outputs }}/kustomization.yaml
git commit -m "Update apps/tad/overlays/${{ steps.get_deploy_env.outputs }}/kustomization.yaml"
laurensWe marked this conversation as resolved.
Show resolved Hide resolved
git push
3 changes: 3 additions & 0 deletions .github/workflows/first-interaction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: first-interaction

on: [pull_request, issues]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
greeting:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/stale-pr-schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
- cron: "0 4 * * *"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
stale:
runs-on: ubuntu-latest
Expand Down