Skip to content

Commit

Permalink
[NOD-473] fix: refactored code
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-deri committed Sep 21, 2023
1 parent 6d9c22e commit 7c26609
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 33 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/04_release_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ jobs:
steps:
- name: Semver setup
id: semver_setup
uses: pagopa/github-actions-template/node-semver-setup@ff1d20edd8236ade3cb06020c273292b9a62d391
uses: pagopa/github-actions-template/node-semver-setup@a1b72480e9ac555364be0b7ecdcc8f5ab1c89ad9
with:
semver: ${{ inputs.semver }}

# Set deploy variables
- run: echo "ENV_SHORT=$(echo ${{steps.semver_setup.outputs.environment}} | cut -c1-1)" >> $GITHUB_ENV
Expand Down Expand Up @@ -115,14 +117,14 @@ jobs:
strategy:
matrix:
environment: [ dev, uat, prod ]
secrets: inherit
uses: ./.github/workflows/04_self_hosted.yml
with:
environment: ${{ matrix.environment }}
target: ${{ needs.setup.outputs.environment }}
resource_group: ${{ needs.setup.outputs.resource_group }}
app_name: ${{ needs.setup.outputs.app_name }}
registry_image: ${{ needs.release.outputs.registry_image }}
secrets: inherit

notify:
name: Notify
Expand All @@ -136,9 +138,9 @@ jobs:
with:
status: ${{ needs.deploy_azure_fn.result }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: 'New Release on ${{ needs.setup.outputs.environment }} ${{ needs.release.outputs.version }} has {status_message}'
notification_title: 'New Release on ${{ needs.setup.outputs.environment }} for ${{ needs.release.outputs.version }} has {status_message}'
message_format: '{emoji} <{run_url}|{workflow}> {status_message} in <{repo_url}|{repo}>'
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 }}
76 changes: 48 additions & 28 deletions .github/workflows/04_self_hosted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,55 +29,75 @@ permissions:
contents: read

jobs:
show_input:
runs-on: ubuntu-latest
if: ${{ inputs.target == inputs.environment }}
steps:
- name: Get input parameters
run: |
echo environment=${{ inputs.environment }}
echo target=${{ inputs.target }}
echo resource_group=${{ inputs.resource_group }}
echo app_name=${{ inputs.app_name }}
echo registry_image=${{ inputs.registry_image }}

# Starting the Azure Function's staging slot, if deploying in PROD
start_staging_slot:
name: Create staging slots
runs-on: ubuntu-22.04
if: ${{ inputs.target == inputs.environment && inputs.target == 'prod' }}
environment:
name: ${{ inputs.environment }}
uses: pagopa/github-actions-template/azure-function-start-staging-slot@ff1d20edd8236ade3cb06020c273292b9a62d391
with:
branch: ${{ github.ref_name }}
client_id: ${{ secrets.CLIENT_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
resource_group: ${{ inputs.resource_group }}
app_name: ${{ inputs.app_name }}
registry_image: ${{ inputs.registry_image }}
steps:
- name: Create staging slots
uses: pagopa/github-actions-template/azure-function-start-staging-slot@a1b72480e9ac555364be0b7ecdcc8f5ab1c89ad9
with:
branch: ${{ github.ref_name }}
client_id: ${{ secrets.CLIENT_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
resource_group: ${{ inputs.resource_group }}
app_name: ${{ inputs.app_name }}
registry_image: ${{ inputs.registry_image }}


# Executing the deploy of the Azure function with the new image
deploy:
name: Deploy Azure Function
runs-on: ubuntu-22.04
needs: [ create_staging_slot ]
needs: [ start_staging_slot ]
if: ${{ always() && inputs.target == inputs.environment }}
environment:
name: ${{ inputs.environment }}
uses: pagopa/github-actions-template/azure-function-deploy@ff1d20edd8236ade3cb06020c273292b9a62d391
with:
branch: ${{ github.ref_name }}
client_id: ${{ secrets.CLIENT_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
app_name: ${{ inputs.app_name }}
registry_image: ${{ inputs.registry_image }}
steps:
- name: Deploy Azure Function
uses: pagopa/github-actions-template/azure-functions-deploy@a1b72480e9ac555364be0b7ecdcc8f5ab1c89ad9
with:
branch: ${{ github.ref_name }}
client_id: ${{ secrets.CLIENT_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
app_name: ${{ inputs.app_name }}
registry_image: ${{ inputs.registry_image }}


# Stopping the Azure Function's staging slot, if deploying in PROD
stop_staging_slot:
name: Clean staging slots
needs: [ create_staging_slot, deploy ]
needs: [ start_staging_slot, deploy ]
if: ${{ success() || failure() && (inputs.target == inputs.environment && inputs.target == 'prod') }}
runs-on: ubuntu-22.04
environment:
name: ${{ inputs.environment }}
uses: pagopa/github-actions-template/azure-function-stop-staging-slot@ff1d20edd8236ade3cb06020c273292b9a62d391
with:
branch: ${{ github.ref_name }}
client_id: ${{ secrets.CLIENT_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
resource_group: ${{ inputs.resource_group }}
app_name: ${{ inputs.app_name }}
registry_image: ${{ inputs.registry_image }}
steps:
- name: Deploy Azure Function
uses: pagopa/github-actions-template/azure-function-stop-staging-slot@a1b72480e9ac555364be0b7ecdcc8f5ab1c89ad9
with:
branch: ${{ github.ref_name }}
client_id: ${{ secrets.CLIENT_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
resource_group: ${{ inputs.resource_group }}
app_name: ${{ inputs.app_name }}
registry_image: ${{ inputs.registry_image }}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>it.gov.pagopa</groupId>
<artifactId>nodoretotablestorage</artifactId>
<version>0.1.2-4-NOD-473-migrazione-cd-su-git-hub-action-per-nodo-re-to-tablestorage</version>
<version>0.1.2</version>
<packaging>jar</packaging>

<name>Nodo RE to Table Storage Fn</name>
Expand Down

0 comments on commit 7c26609

Please sign in to comment.