Release #712
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: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Existing Version to release (*Blank to create a new one)' | |
required: false | |
environment: | |
description: 'The target environment for deployment' | |
type: environment | |
required: true | |
modules: | |
description: 'Modules you want to deploy (*Names separated by comma, *Blank to deploy every modules)' | |
required: false | |
permissions: | |
contents: write | |
env: | |
BOT_USER: Actions Bot | |
BOT_MAIL: <> | |
jobs: | |
CheckInputModules: | |
name: Check Input Modules | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.inputs.environment }} | |
outputs: | |
fe-piattaforma: ${{ steps.modules.outputs.fe-piattaforma }} | |
ms-ente: ${{ steps.modules.outputs.ms-ente }} | |
ms-gestione-utente: ${{ steps.modules.outputs.ms-gestione-utente }} | |
ms-notifiche-integration: ${{ steps.modules.outputs.ms-notifiche-integration }} | |
ms-open-data: ${{ steps.modules.outputs.ms-open-data }} | |
ms-programma-progetto: ${{ steps.modules.outputs.ms-programma-progetto }} | |
ms-questionario-cittadino: ${{ steps.modules.outputs.ms-questionario-cittadino }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# this allow the workflow to be rerun after changes have been pushed from previous jobs | |
ref: ${{ github.ref }} | |
fetch-depth: 0 | |
- name: Set modules required | |
id: modules | |
run: | | |
environment="${{ github.event.inputs.environment }}" | |
in="${{ github.event.inputs.modules }}" | |
in=${in// /} | |
if [[ "$in" != "" ]] && [[ "$environment" == "Development" ]]; then | |
echo "fe-piattaforma=false" >> $GITHUB_OUTPUT | |
echo "ms-ente=false" >> $GITHUB_OUTPUT | |
echo "ms-gestione-utente=false" >> $GITHUB_OUTPUT | |
echo "ms-notifiche-integration=false" >> $GITHUB_OUTPUT | |
echo "ms-open-data=false" >> $GITHUB_OUTPUT | |
echo "ms-programma-progetto=false" >> $GITHUB_OUTPUT | |
echo "ms-questionario-cittadino=false" >> $GITHUB_OUTPUT | |
arrIN=(${in//,/ }) | |
for i in "${arrIN[@]}"; do | |
case $i in | |
fe-piattaforma) | |
echo "fe-piattaforma=true" >> $GITHUB_OUTPUT | |
;; | |
ms-ente) | |
echo "ms-ente=true" >> $GITHUB_OUTPUT | |
;; | |
ms-gestione-utente) | |
echo "ms-gestione-utente=true" >> $GITHUB_OUTPUT | |
;; | |
ms-notifiche-integration) | |
echo "ms-notifiche-integration=true" >> $GITHUB_OUTPUT | |
;; | |
ms-open-data) | |
echo "ms-open-data=true" >> $GITHUB_OUTPUT | |
;; | |
ms-programma-progetto) | |
echo "ms-programma-progetto=true" >> $GITHUB_OUTPUT | |
;; | |
ms-questionario-cittadino) | |
echo "ms-questionario-cittadino=true" >> $GITHUB_OUTPUT | |
;; | |
*) | |
echo "Unknown $i" | |
exit 1 | |
;; | |
esac | |
done | |
else | |
echo "fe-piattaforma=true" >> $GITHUB_OUTPUT | |
echo "ms-ente=true" >> $GITHUB_OUTPUT | |
echo "ms-gestione-utente=true" >> $GITHUB_OUTPUT | |
echo "ms-notifiche-integration=true" >> $GITHUB_OUTPUT | |
echo "ms-open-data=true" >> $GITHUB_OUTPUT | |
echo "ms-programma-progetto=true" >> $GITHUB_OUTPUT | |
echo "ms-questionario-cittadino=true" >> $GITHUB_OUTPUT | |
fi | |
DryRunRelease: | |
needs: CheckInputModules | |
name: Dry-Run Release | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.inputs.environment }} | |
outputs: | |
version: ${{ steps.version.outputs.VERSION }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# this allow the workflow to be rerun after changes have been pushed from previous jobs | |
ref: ${{ github.ref }} | |
fetch-depth: 0 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 'lts/*' | |
- name: Install semantic-release extra plugins | |
run: | | |
npm install --save-dev \ | |
semantic-release \ | |
@semantic-release/commit-analyzer \ | |
@semantic-release/changelog \ | |
@semantic-release/git \ | |
@semantic-release/release-notes-generator \ | |
@semantic-release/exec \ | |
conventional-changelog-conventionalcommits | |
- name: Create .VERSION file | |
run: echo "There are no relevant changes, so no new version is released" > .VERSION | |
- name: Dry-Run | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
npx semantic-release --dry-run --no-ci | |
- name: Version | |
id: version | |
run: | | |
nextversion=$(cat .VERSION) | |
echo "VERSION=$nextversion" >> $GITHUB_OUTPUT | |
echo "Next version: $nextversion" | |
- name: Check changes | |
if: ${{ github.event.inputs.version == '' }} | |
run: | | |
nextversion=$(cat .VERSION) | |
regex="^(([0-9]+).([0-9]+).([0-9]+)(-[A-Za-z]*.[0-9]*)?)$" | |
if [[ $nextversion =~ $regex ]]; then | |
echo "===> Changes detected: Release started!" | |
else | |
echo "===> No changes detected: Release stopped!" | |
echo "### No relevant changes detected: no new version is released!" >> $GITHUB_STEP_SUMMARY | |
exit 1 | |
fi | |
buildFE: | |
if: ${{ github.event.inputs.version == '' && needs.CheckInputModules.outputs.fe-piattaforma == 'true' }} | |
needs: [CheckInputModules, DryRunRelease] | |
name: FE Build | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.inputs.environment }} | |
defaults: | |
run: | |
shell: bash | |
working-directory: ${{ github.workspace }}/fe-piattaforma | |
steps: | |
- uses: actions/checkout@v3.0.2 | |
with: | |
# this allow the workflow to be rerun after changes have been pushed from previous jobs | |
ref: ${{ github.ref }} | |
lfs: 'true' | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 'lts/*' | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Modify Env File | |
run: | | |
sed -i "s/{{_REACT_APP_BE_BASE_URL_}}/${{ secrets.REACT_APP_BE_BASE_URL }}/g" .env | |
sed -i "s/{{_REACT_APP_COGNITO_BASE_URL_}}/${{ secrets.REACT_APP_COGNITO_BASE_URL }}/g" .env | |
sed -i "s/{{_REACT_APP_COGNITO_CLIENT_ID_}}/${{ secrets.REACT_APP_COGNITO_CLIENT_ID }}/g" .env | |
sed -i "s/{{_REACT_APP_COGNITO_CLIENT_SECRET_}}/${{ secrets.REACT_APP_COGNITO_CLIENT_SECRET }}/g" .env | |
sed -i "s/{{_REACT_APP_COGNITO_FE_REDIRECT_URL_}}/${{ secrets.REACT_APP_COGNITO_FE_REDIRECT_URL }}/g" .env | |
sed -i "s/{{_REACT_APP_DASHBOARD_BASE_URL_}}/${{ secrets.REACT_APP_DASHBOARD_BASE_URL }}/g" .env | |
sed -i "s/{{_REACT_APP_DASHBOARD_BI_URL_}}/${{ secrets.REACT_APP_DASHBOARD_BI_URL }}/g" .env | |
sed -i "s/{{_REACT_APP_DRUPAL_BASE_URL_}}/${{ secrets.REACT_APP_DRUPAL_BASE_URL }}/g" .env | |
sed -i "s/{{_REACT_APP_DRUPAL_SETTINGS_}}/${{ secrets.REACT_APP_DRUPAL_SETTINGS }}/g" .env | |
sed -i "s/{{_REACT_APP_ROCKET_CHAT_BASE_URL_}}/${{ secrets.REACT_APP_ROCKET_CHAT_BASE_URL }}/g" .env | |
sed -i "s/{{_REACT_APP_ROCKET_CHAT_SETTINGS_}}/${{ secrets.REACT_APP_ROCKET_CHAT_SETTINGS }}/g" .env | |
sed -i "s/{{_REACT_APP_WORKDOCS_BASE_URL_}}/${{ secrets.REACT_APP_WORKDOCS_BASE_URL }}/g" .env | |
sed -i "s/{{_REACT_APP_WORKDOCS_SETTINGS_}}/${{ secrets.REACT_APP_WORKDOCS_SETTINGS }}/g" .env | |
sed -i "s/{{_REACT_APP_QUICKSIGHT_BASE_URL_}}/${{ secrets.REACT_APP_QUICKSIGHT_BASE_URL }}/g" .env | |
sed -i "s/{{_REACT_APP_QUICKSIGHT_SETTINGS_}}/${{ secrets.REACT_APP_QUICKSIGHT_SETTINGS }}/g" .env | |
- name: File Regex Replace | |
uses: mingjun97/file-regex-replace@v1 | |
with: | |
# regex to apply(regex) | |
regex: '"version":[\s\S]"[0-9].[0-9].[0-9]"' | |
# flags of the regex | |
flags: "gmi" | |
# replacement string | |
replacement: '"version": "${{needs.DryRunRelease.outputs.version}}"' | |
# Files to be replaced(regex) | |
include: "package.json" | |
- name: Install FE dependencies | |
run: | | |
npm install --force | |
- name: Build & Push Image to Amazon ECR | |
id: build | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: fe-piattaforma | |
IMAGE_TAG: ${{needs.DryRunRelease.outputs.version}} | |
run: | | |
npm run build | |
docker build . \ | |
--target builder \ | |
--file Dockerfile \ | |
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
buildBE: | |
if: ${{ github.event.inputs.version == '' && (needs.CheckInputModules.outputs.ms-ente == 'true' || | |
needs.CheckInputModules.outputs.ms-gestione-utente == 'true' || needs.CheckInputModules.outputs.ms-notifiche-integration == 'true' || | |
needs.CheckInputModules.outputs.ms-open-data == 'true' || needs.CheckInputModules.outputs.ms-programma-progetto == 'true' || | |
needs.CheckInputModules.outputs.ms-questionario-cittadino == 'true' ) }} | |
needs: [CheckInputModules, DryRunRelease] | |
name: BE Build | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.inputs.environment }} | |
steps: | |
- uses: actions/checkout@v3.0.2 | |
with: | |
# this allow the workflow to be rerun after changes have been pushed from previous jobs | |
ref: ${{ github.ref }} | |
lfs: 'true' | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'adopt-openj9' | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Install Lib repdgt-shared | |
if: ${{ success() }} | |
run: | | |
cd ${{ github.workspace }}/lib-repdgt-shared | |
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}} | |
mvn install | |
- name: ms-ente Build & Push Image to Amazon ECR | |
id: ms-ente | |
if: ${{ success() && needs.CheckInputModules.outputs.ms-ente == 'true' }} | |
working-directory: ${{ github.workspace }}/ms-ente | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ms-ente | |
IMAGE_TAG: ${{needs.DryRunRelease.outputs.version}} | |
run: | | |
# set version | |
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}} | |
# build | |
mvn package | |
echo "======DOCKERFILE======" | |
cat Dockerfile | |
echo "=====================" | |
# docker build | |
docker build . \ | |
--file Dockerfile \ | |
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
# docker push | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
- name: ms-gestione-utente Build & Push Image to Amazon ECR | |
id: ms-gestione-utente | |
if: ${{ success() && needs.CheckInputModules.outputs.ms-gestione-utente == 'true' }} | |
working-directory: ${{ github.workspace }}/ms-gestione-utente | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ms-gestione-utente | |
IMAGE_TAG: ${{needs.DryRunRelease.outputs.version}} | |
run: | | |
# set version | |
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}} | |
# build | |
mvn package | |
echo "======DOCKERFILE======" | |
cat Dockerfile | |
echo "=====================" | |
# docker build | |
docker build . \ | |
--file Dockerfile \ | |
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
# docker push | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
- name: ms-notifiche-integration Build & Push Image to Amazon ECR | |
id: ms-notifiche-integration | |
if: ${{ success() && needs.CheckInputModules.outputs.ms-notifiche-integration == 'true' }} | |
working-directory: ${{ github.workspace }}/ms-notifiche-integration | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ms-notifiche-integration | |
IMAGE_TAG: ${{needs.DryRunRelease.outputs.version}} | |
run: | | |
# set version | |
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}} | |
# build | |
mvn package | |
echo "======DOCKERFILE======" | |
cat Dockerfile | |
echo "=====================" | |
# docker build | |
docker build . \ | |
--file Dockerfile \ | |
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
# docker push | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
- name: ms-open-data Build & Push Image to Amazon ECR | |
id: ms-open-data | |
if: ${{ success() && needs.CheckInputModules.outputs.ms-open-data == 'true' }} | |
working-directory: ${{ github.workspace }}/ms-open-data | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ms-open-data | |
IMAGE_TAG: ${{needs.DryRunRelease.outputs.version}} | |
run: | | |
# set version | |
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}} | |
# build | |
mvn package | |
echo "======DOCKERFILE======" | |
cat Dockerfile | |
echo "=====================" | |
# docker build | |
docker build . \ | |
--file Dockerfile \ | |
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
# docker push | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
- name: ms-programma-progetto Build & Push Image to Amazon ECR | |
id: ms-programma-progetto | |
if: ${{ success() && needs.CheckInputModules.outputs.ms-programma-progetto == 'true' }} | |
working-directory: ${{ github.workspace }}/ms-programma-progetto | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ms-programma-progetto | |
IMAGE_TAG: ${{needs.DryRunRelease.outputs.version}} | |
run: | | |
# set version | |
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}} | |
# build | |
mvn package | |
echo "======DOCKERFILE======" | |
cat Dockerfile | |
echo "=====================" | |
# docker build | |
docker build . \ | |
--file Dockerfile \ | |
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
# docker push | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
- name: ms-questionario-cittadino Build & Push Image to Amazon ECR | |
id: ms-questionario-cittadino | |
if: ${{ success() && needs.CheckInputModules.outputs.ms-questionario-cittadino == 'true' }} | |
working-directory: ${{ github.workspace }}/ms-questionario-cittadino | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ms-questionario-cittadino | |
IMAGE_TAG: ${{needs.DryRunRelease.outputs.version}} | |
run: | | |
# set version | |
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}} | |
# build | |
mvn package | |
echo "======DOCKERFILE======" | |
cat Dockerfile | |
echo "=====================" | |
# docker build | |
docker build . \ | |
--file Dockerfile \ | |
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
# docker push | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
Deploy: | |
needs: [CheckInputModules, DryRunRelease, buildFE, buildBE] | |
if: ${{ always() && | |
needs.DryRunRelease.result == 'success' && | |
(needs.buildFE.result == 'success' || needs.buildFE.result == 'skipped') && | |
(needs.buildBE.result == 'success' || needs.buildBE.result == 'skipped') }} | |
name: Deploy | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.inputs.environment }} | |
defaults: | |
run: | |
shell: bash | |
outputs: | |
IMAGETAG: ${{ steps.imagetag.outputs.IMAGETAG }} | |
steps: | |
- uses: actions/checkout@v3.0.2 | |
with: | |
# this allow the workflow to be rerun after changes have been pushed from previous jobs | |
ref: ${{ github.ref }} | |
fetch-depth: '0' | |
- name: Check Input Version | |
if: ${{ github.event.inputs.version != '' }} | |
id: checkver | |
run: | | |
version="${{ github.event.inputs.version }}" | |
echo "==> Version: $version" | |
if [ $(git tag -l "$version" | wc -l) -gt 0 ]; then | |
echo "Version $version exists. Input accepted." | |
else | |
echo "Version $version doesn't exist. INVALID INPUT." | |
exit 1 | |
fi | |
- uses: azure/setup-kubectl@v3.0 | |
with: | |
version: 'v1.23.6' # default is latest stable | |
id: install | |
- name: Configure AWS credentials for ECR | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Configure AWS credentials for K8S | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
role-session-name: Git | |
role-duration-seconds: 3600 | |
- name: Setup Kubeconfig | |
run: | | |
aws eks update-kubeconfig --region ${{ secrets.AWS_REGION }} --name ${{ secrets.AWS_CLUSTER }} | |
- name: Setup Image TAG | |
id: imagetag | |
run: | | |
if [ "${{ github.event.inputs.version }}" = "" ]; then | |
echo "IMAGETAG=$(echo ${{needs.DryRunRelease.outputs.version}} )" >> $GITHUB_OUTPUT | |
else | |
echo "IMAGETAG=$(echo ${{ github.event.inputs.version }} )" >> $GITHUB_OUTPUT | |
fi | |
- name: Setup 'fe-piattaforma' deployment.tmp.yaml | |
if: ${{ success() && needs.CheckInputModules.outputs.fe-piattaforma == 'true' }} | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: fe-piattaforma | |
IMAGE_TAG: ${{ steps.imagetag.outputs.IMAGETAG }} | |
run: | | |
cd ${{ github.workspace }}/fe-piattaforma/k8s | |
export ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY | |
export IMAGE_TAG=$IMAGE_TAG | |
export K8S_NAMESPACE=${{ secrets.K8S_NAMESPACE }} | |
export K8S_INGRESS_CERTIFICATE=${{ secrets.K8S_INGRESS_CERTIFICATE }} | |
envsubst < deployment.tmp.yml >> ${{ github.workspace }}/deployment.yml | |
- name: Setup 'ms-ente' deployment.tmp.yaml | |
if: ${{ success() && needs.CheckInputModules.outputs.ms-ente == 'true' }} | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ms-ente | |
IMAGE_TAG: ${{ steps.imagetag.outputs.IMAGETAG }} | |
run: | | |
cd ${{ github.workspace }}/ms-ente/k8s | |
export ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY | |
export IMAGE_TAG=$IMAGE_TAG | |
export K8S_NAMESPACE=${{ secrets.K8S_NAMESPACE }} | |
envsubst < deployment.tmp.yml >> ${{ github.workspace }}/deployment.yml | |
- name: Setup 'ms-gestione-utente' deployment.tmp.yaml | |
if: ${{ success() && needs.CheckInputModules.outputs.ms-gestione-utente == 'true' }} | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ms-gestione-utente | |
IMAGE_TAG: ${{ steps.imagetag.outputs.IMAGETAG }} | |
run: | | |
cd ${{ github.workspace }}/ms-gestione-utente/k8s | |
export ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY | |
export IMAGE_TAG=$IMAGE_TAG | |
export K8S_NAMESPACE=${{ secrets.K8S_NAMESPACE }} | |
envsubst < deployment.tmp.yml >> ${{ github.workspace }}/deployment.yml | |
- name: Setup 'ms-notifiche-integration' deployment.tmp.yaml | |
if: ${{ success() && needs.CheckInputModules.outputs.ms-notifiche-integration == 'true' }} | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ms-notifiche-integration | |
IMAGE_TAG: ${{ steps.imagetag.outputs.IMAGETAG }} | |
run: | | |
cd ${{ github.workspace }}/ms-notifiche-integration/k8s | |
export ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY | |
export IMAGE_TAG=$IMAGE_TAG | |
export K8S_NAMESPACE=${{ secrets.K8S_NAMESPACE }} | |
envsubst < deployment.tmp.yml >> ${{ github.workspace }}/deployment.yml | |
- name: Setup 'ms-open-data' deployment.tmp.yaml | |
if: ${{ success() && needs.CheckInputModules.outputs.ms-open-data == 'true' }} | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ms-open-data | |
IMAGE_TAG: ${{ steps.imagetag.outputs.IMAGETAG }} | |
run: | | |
cd ${{ github.workspace }}/ms-open-data/k8s | |
export ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY | |
export IMAGE_TAG=$IMAGE_TAG | |
export K8S_NAMESPACE=${{ secrets.K8S_NAMESPACE }} | |
envsubst < deployment.tmp.yml >> ${{ github.workspace }}/deployment.yml | |
- name: Setup 'ms-programma-progetto' deployment.tmp.yaml | |
if: ${{ success() && needs.CheckInputModules.outputs.ms-programma-progetto == 'true' }} | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ms-programma-progetto | |
IMAGE_TAG: ${{ steps.imagetag.outputs.IMAGETAG }} | |
run: | | |
cd ${{ github.workspace }}/ms-programma-progetto/k8s | |
export ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY | |
export IMAGE_TAG=$IMAGE_TAG | |
export K8S_NAMESPACE=${{ secrets.K8S_NAMESPACE }} | |
envsubst < deployment.tmp.yml >> ${{ github.workspace }}/deployment.yml | |
- name: Setup 'ms-questionario-cittadino' deployment.tmp.yaml | |
if: ${{ success() && needs.CheckInputModules.outputs.ms-questionario-cittadino == 'true' }} | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ms-questionario-cittadino | |
IMAGE_TAG: ${{ steps.imagetag.outputs.IMAGETAG }} | |
run: | | |
cd ${{ github.workspace }}/ms-questionario-cittadino/k8s | |
export ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY | |
export IMAGE_TAG=$IMAGE_TAG | |
export K8S_NAMESPACE=${{ secrets.K8S_NAMESPACE }} | |
envsubst < deployment.tmp.yml >> ${{ github.workspace }}/deployment.yml | |
- name: Deploy | |
run: | | |
cd ${{ github.workspace }} | |
echo "===DEPLOYMENT FILE===" | |
cat deployment.yml | |
echo "=====================" | |
kubectl apply -f deployment.yml | |
RepoUpdate: | |
needs: [CheckInputModules, DryRunRelease, Deploy] | |
if: ${{ github.event.inputs.version == '' && always() && | |
needs.CheckInputModules.result == 'success' && needs.DryRunRelease.result == 'success' && needs.Deploy.result == 'success' && | |
(needs.buildFE.result == 'success' || needs.buildFE.result == 'skipped') && | |
(needs.buildBE.result == 'success' || needs.buildBE.result == 'skipped') }} | |
name: Repo Update | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.inputs.environment }} | |
defaults: | |
run: | |
shell: bash | |
working-directory: ${{ github.workspace }}/fe-piattaforma | |
steps: | |
- uses: actions/checkout@v3.0.2 | |
with: | |
token: ${{ secrets.PAT_REPDIGITALE_AUTOMATION }} | |
# this allow the workflow to be rerun after changes have been pushed from previous jobs | |
ref: ${{ github.ref }} | |
persist-credentials: 'true' | |
fetch-depth: '0' | |
- name: File Package Update | |
if: ${{ needs.CheckInputModules.outputs.fe-piattaforma == 'true' }} | |
uses: mingjun97/file-regex-replace@v1 | |
with: | |
# regex to apply(regex) | |
regex: '"version":[\s\S]"[0-9].[0-9].[0-9]"' | |
# flags of the regex | |
flags: "gmi" | |
# replacement string | |
replacement: '"version": "${{needs.DryRunRelease.outputs.version}}"' | |
# Files to be replaced(regex) | |
include: "package.json" | |
- name: File POM Update | |
if: ${{ success() }} | |
run: | | |
cd ${{ github.workspace }}/lib-repdgt-shared | |
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}} | |
in="${{ needs.CheckInputModules.outputs.ms-ente }}" | |
if [ "$in" == "true" ]; then | |
cd ${{ github.workspace }}/ms-ente | |
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}} | |
fi | |
in="${{ needs.CheckInputModules.outputs.ms-gestione-utente }}" | |
if [ "$in" == "true" ]; then | |
cd ${{ github.workspace }}/ms-gestione-utente | |
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}} | |
fi | |
in="${{ needs.CheckInputModules.outputs.ms-notifiche-integration }}" | |
if [ "$in" == "true" ]; then | |
cd ${{ github.workspace }}/ms-notifiche-integration | |
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}} | |
fi | |
in="${{ needs.CheckInputModules.outputs.ms-open-data }}" | |
if [ "$in" == "true" ]; then | |
cd ${{ github.workspace }}/ms-open-data | |
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}} | |
fi | |
in="${{ needs.CheckInputModules.outputs.ms-programma-progetto }}" | |
if [ "$in" == "true" ]; then | |
cd ${{ github.workspace }}/ms-programma-progetto | |
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}} | |
fi | |
in="${{ needs.CheckInputModules.outputs.ms-questionario-cittadino }}" | |
if [ "$in" == "true" ]; then | |
cd ${{ github.workspace }}/ms-questionario-cittadino | |
mvn versions:set -DnewVersion=${{needs.DryRunRelease.outputs.version}} | |
fi | |
- name: Push files updated | |
run: | | |
cd ${{ github.workspace }} | |
git diff | |
git config user.email "$BOT_MAIL" | |
git config user.name "$BOT_USER" | |
git add -A | |
git commit -m "chore: update version ${{needs.DryRunRelease.outputs.version}}" || exit 0 | |
git push | |
Release: | |
needs: [RepoUpdate] | |
if: ${{ github.event.inputs.version == '' && always() && needs.RepoUpdate.result == 'success' }} | |
name: Release | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.inputs.environment }} | |
steps: | |
- uses: actions/checkout@v3.0.2 | |
with: | |
# this allow the workflow to be rerun after changes have been pushed from previous jobs | |
ref: ${{ github.ref }} | |
token: ${{ secrets.PAT_REPDIGITALE_AUTOMATION }} | |
persist-credentials: 'true' | |
fetch-depth: '0' | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 'lts/*' | |
- name: Install semantic-release extra plugins | |
run: | | |
npm install --save-dev \ | |
semantic-release \ | |
@semantic-release/commit-analyzer \ | |
@semantic-release/changelog \ | |
@semantic-release/git \ | |
@semantic-release/release-notes-generator \ | |
@semantic-release/exec \ | |
conventional-changelog-conventionalcommits | |
- name: Create .VERSION file | |
run: echo "There are no relevant changes, so no new version is released" > .VERSION | |
- name: Release | |
env: | |
# ad-hoc token (PAT) in order to permit the push on a protected branch | |
# without protected branches can be use secrets.GITHUB_TOKEN | |
GITHUB_TOKEN: ${{ secrets.PAT_REPDIGITALE_AUTOMATION }} | |
run: | | |
npx semantic-release | |
- name: Version | |
id: version | |
run: | | |
nextversion=$(cat .VERSION) | |
echo "VERSION=$nextversion" >> $GITHUB_OUTPUT | |
echo "### Release $nextversion created!" >> $GITHUB_STEP_SUMMARY |