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

chore: Fix GH #6

Merged
merged 1 commit into from
May 12, 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
9 changes: 2 additions & 7 deletions .github/workflows/deploy_with_github_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ on:
required: true
description: The name of the environment where to deploy
type: string
target:
required: true
description: The environment target of the job
type: string

env:
APP_NAME: authorizerconfig
Expand All @@ -26,7 +22,6 @@ jobs:
runs-on: ubuntu-22.04
environment:
name: ${{ inputs.environment }}
if: ${{ inputs.target == inputs.environment || inputs.target == 'all' }}
outputs:
runner_name: ${{ steps.create_github_runner.outputs.runner_name }}
steps:
Expand All @@ -45,7 +40,6 @@ jobs:
deploy:
needs: [ create_runner ]
runs-on: [ self-hosted, "${{ needs.create_runner.outputs.runner_name }}" ]
if: ${{ inputs.target == inputs.environment || inputs.target == 'all' }}
name: Deploy on AKS
environment: ${{ inputs.environment }}
steps:
Expand All @@ -62,11 +56,12 @@ jobs:
resource_group: ${{ vars.CLUSTER_RESOURCE_GROUP }}
app_name: ${{ env.APP_NAME }}
helm_upgrade_options: "--debug"
timeout: '10m0s'

cleanup_runner:
name: Cleanup Runner
needs: [ create_runner, deploy ]
if: ${{ success() || failure() && inputs.target == inputs.environment || inputs.target == 'all' }}
if: ${{ success() || failure() }}
runs-on: ubuntu-22.04
environment: ${{ inputs.environment }}
steps:
Expand Down
81 changes: 56 additions & 25 deletions .github/workflows/release_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ on:
- dev
- uat
- prod
- all
version:
required: false
type: choice
description: Select the version
options:
- ''
- skip
- promote
- new_release
- breaking_change

beta:
required: false
type: boolean
description: deploy beta version on AKS
default: false
skip_release:
required: false
type: boolean
description: skip the release. Only deploy
default: false


permissions:
Expand Down Expand Up @@ -58,16 +63,17 @@ jobs:
- if: ${{ (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'breaking-change')) }}
run: echo "SEMVER=major" >> $GITHUB_ENV

- if: ${{ inputs.environment == 'uat' }}
# force semver if dev, !=main or skip release
- if: ${{ inputs.version == 'new_release' }}
run: echo "SEMVER=minor" >> $GITHUB_ENV

- if: ${{ inputs.environment == 'prod' }}
run: echo "SEMVER=skip" >> $GITHUB_ENV
- if: ${{ inputs.version == 'breaking_change' }}
run: echo "SEMVER=major" >> $GITHUB_ENV

- if: ${{ github.ref_name != 'main' }}
run: echo "SEMVER=buildNumber" >> $GITHUB_ENV

- if: ${{ inputs.skip_release }}
- if: ${{ inputs.version == 'skip' || inputs.version == 'promote' }}
run: echo "SEMVER=skip" >> $GITHUB_ENV

- id: get_semver
Expand Down Expand Up @@ -105,27 +111,52 @@ jobs:
needs: [ setup, release ]
name: Build and Push Docker Image
runs-on: ubuntu-latest
if: ${{ inputs.semver != 'skip' }}
if: ${{ needs.setup.outputs.semver != 'skip' }}
steps:
- name: Build and Push
id: semver
uses: pagopa/github-actions-template/[email protected]
# - name: Build and Push
# id: semver
# uses: pagopa/github-actions-template/[email protected]
# with:
# branch: ${{ github.ref_name}}
# github_token: ${{ secrets.GITHUB_TOKEN }}
# tag: ${{ needs.release.outputs.version }}
- uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}
tags: |
latest
${{ needs.release.outputs.version }}
type=ref,event=branch
type=sha

- name: Build and push
uses: docker/build-push-action@v4
with:
branch: ${{ github.ref_name}}
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.release.outputs.version }}
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

deploy_aks:
name: Deploy on AKS
name: Deploy on AKS ${{needs.setup.outputs.environment}}
needs: [ setup, release, image ]
if: ${{ always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
strategy:
matrix:
environment: [ dev, uat, prod ]
uses: ./.github/workflows/deploy_with_github_runner.yml
with:
environment: ${{ matrix.environment }}
target: ${{ needs.setup.outputs.environment }}
environment: ${{ needs.setup.outputs.environment }}
secrets: inherit

notify:
Expand All @@ -135,7 +166,7 @@ jobs:
if: always()
steps:
- name: Report Status
if: ${{ needs.setup.outputs.environment == 'prod' || needs.setup.outputs.environment == 'all' }}
if: ${{ needs.setup.outputs.environment == 'prod' }}
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ needs.deploy_aks.result }}
Expand All @@ -145,4 +176,4 @@ jobs:
footer: 'Linked to <{workflow_url}| workflow file>'
icon_success: ':white_check_mark:'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Loading