Next Release 1.40.0 #169
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CD UAT/PROD | |
on: | |
pull_request: | |
branches: [ main ] | |
types: [ closed ] | |
permissions: | |
packages: write | |
contents: write | |
issues: write | |
id-token: write | |
actions: read | |
jobs: | |
setup: | |
name: Setup | |
runs-on: ubuntu-latest | |
outputs: | |
semver: ${{ steps.get_semver.outputs.semver }} | |
steps: | |
- name: pull request rejected | |
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged != true | |
run: | | |
echo "❌ PR was closed without a merge" | |
exit 1 | |
# Set Semvar | |
- run: echo "SEMVER=patch" >> $GITHUB_ENV | |
- if: ${{ (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'skip')) }} | |
run: echo "SEMVER=skip" >> $GITHUB_ENV | |
- if: ${{ (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'patch')) }} | |
run: echo "SEMVER=patch" >> $GITHUB_ENV | |
- if: ${{ (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'minor')) }} | |
run: echo "SEMVER=minor" >> $GITHUB_ENV | |
- if: ${{ (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'major')) }} | |
run: echo "SEMVER=major" >> $GITHUB_ENV | |
- id: get_semver | |
name: Set Output | |
run: echo "semver=${{env.SEMVER}}" >> $GITHUB_OUTPUT | |
pre_release: | |
name: Create a New Pre-Release | |
runs-on: ubuntu-latest | |
needs: [ setup ] | |
if: ${{ needs.setup.outputs.semver != 'skip' }} | |
outputs: | |
version: ${{ steps.release.outputs.version }} | |
steps: | |
- name: Make Release | |
id: release | |
uses: pagopa/github-actions-template/node-release@473d7a78d28e15cab46dcaf766087e60604d6a40 # v1.13.3 | |
with: | |
semver: ${{ needs.setup.outputs.semver }} | |
github_token: ${{ secrets.BOT_TOKEN_GITHUB }} | |
skip_ci: true | |
prerelease: true | |
deploy_uat: | |
name: Deploy in UAT | |
needs: [ setup, pre_release ] | |
uses: ./.github/workflows/deploy_on_cdn.yml | |
with: | |
environment: 'uat' | |
feature_fdr: true | |
feature_qi_fdr: true | |
secrets: inherit | |
# integration_test: | |
# name: Integration Test | |
# needs: [ setup, deploy_uat ] | |
# uses: ./.github/workflows/ci_integration_test.yml | |
# with: | |
# environment: ${{ needs.setup.outputs.environment }} | |
# notify: false | |
# secrets: inherit | |
deploy_prod: | |
needs: | |
- setup | |
- deploy_uat | |
# - integration_test | |
name: Deploy in PROD | |
uses: ./.github/workflows/deploy_on_cdn.yml | |
with: | |
environment: 'prod' | |
feature_fdr: false | |
feature_qi_fdr: false | |
secrets: inherit | |
release: | |
name: Create a New Release | |
runs-on: ubuntu-latest | |
needs: [ setup, pre_release, deploy_prod ] | |
if: ${{ needs.setup.outputs.semver != 'skip' }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 # required to make the script available for next step | |
- name: Make Latest Release | |
id: generate_notes | |
uses: actions/github-script@211cb3fefb35a799baa5156f9321bb774fe56294 # v5 | |
env: | |
RELEASE_TAG: ${{ needs.pre_release.outputs.version }} | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const script = require('./.github/workflows/github_scripts/make_latest_release.js') | |
await script({github, context}) | |
notify: | |
needs: [ setup, deploy_prod, release ] | |
runs-on: ubuntu-latest | |
name: Notify | |
if: always() | |
steps: | |
- name: Report Status | |
uses: ravsamhq/notify-slack-action@be814b201e233b2dc673608aa46e5447c8ab13f2 # v2 | |
with: | |
status: ${{ needs.deploy_prod.result }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
notification_title: 'New Release on Production ${{ 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 }} | |