Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Merge branch 'release/4.0' of https://github.com/vantage6/vantage6-UI… #23

Merge branch 'release/4.0' of https://github.com/vantage6/vantage6-UI…

Merge branch 'release/4.0' of https://github.com/vantage6/vantage6-UI… #23

Workflow file for this run

# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy Node.js app to Azure Web App - ui-cotopaxi
on:
push:
tags:
- "version/**"
jobs:
# Check that the tag that is being used starts with `version/`. If
# this is not the case, this tag is not intended for release.
verify:
name: Verify version tag
runs-on: ubuntu-latest
steps:
- id: verify
if: startsWith(github.ref, 'refs/tags/version') != true
uses: andymckay/cancel-action@0.2
# From the tag we split the individual version components:
# major.minor.patch.stage<N>. Note that post releases are not part
# of this schema as they are only used for releasing updated docker
# images.
version:
name: Obtain version
runs-on: ubuntu-latest
needs: verify
steps:
- id: split
run: |
TAG=${GITHUB_REF#refs/*/}
VERSION=${TAG#version/*}
PARTS=(${VERSION//\./ })
MAJOR=${PARTS[0]}
echo "version=${VERSION}" >> $GITHUB_OUTPUT
PARTS2=( $(grep -Eo '[[:digit:]]+|[^[:digit:]]+' <<< ${PARTS[2]} ) )
echo "stage=${PARTS2[1]}" >> $GITHUB_OUTPUT
MAJOR_NAME=''
if [[ $MAJOR == '4' ]]; then MAJOR_NAME="cotopaxi"; fi
if [[ $MAJOR == '3' ]]; then MAJOR_NAME="petronas"; fi
echo "major_name=${MAJOR_NAME}" >> $GITHUB_OUTPUT
outputs:
version: ${{ steps.split.outputs.version }}
stage: ${{ steps.split.outputs.stage }}
major_name: ${{ steps.split.outputs.major_name }}
# Build artifact for deployment
build:
name: Build deployment artifact
runs-on: ubuntu-latest
needs: version
env:
version: ${{ needs.version.outputs.version }}
steps:
- uses: actions/checkout@v2
- name: Update UI version in package.json
run: |
npm version --no-git-tag-version --allow-same-version $version
- name: Set up Node.js version
uses: actions/setup-node@v1
with:
node-version: "16.x"
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
# npm run test --if-present
- name: Zip artifact for deployment
run: zip release.zip ./* -r
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: node-app
path: release.zip
# Update the server and node images on harbor2 for this major version,
# including the 'live' tag that triggers a redeployment of the IKNL deployment
release-docker:
runs-on: ubuntu-latest
needs: [version, build]
env:
version: ${{ needs.version.outputs.version }}
stage: ${{ needs.version.outputs.stage }}
major_name: ${{ needs.version.outputs.major_name }}
steps:
- name: Login to harbor2.vantage6.ai
env:
USERNAME: ${{ secrets.DOCKER_USERNAME }}
PASSWORD: ${{ secrets.DOCKER_TOKEN }}
run: |
docker login harbor2.vantage6.ai -u $USERNAME -p $PASSWORD
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: "true"
- name: Build docker image
run: |
docker build -t harbor2.vantage6.ai/infrastructure/ui:${version} .
- name: Tag docker images
if: ${{ env.stage == '' && env.major_name != '' }}
run: |
docker tag harbor2.vantage6.ai/infrastructure/ui:${version} harbor2.vantage6.ai/infrastructure/ui:${major_name}
docker tag harbor2.vantage6.ai/infrastructure/ui:${version} harbor2.vantage6.ai/infrastructure/ui:latest
- name: Push version docker image
run: |
docker push harbor2.vantage6.ai/infrastructure/ui:${version}
- name: Push docker images with important tags
if: ${{ env.stage == '' && env.major_name != '' }}
run: |
docker push harbor2.vantage6.ai/infrastructure/ui:${major_name}
docker push harbor2.vantage6.ai/infrastructure/ui:latest
# Deploy to Azure
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: "Production"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: node-app
- name: unzip artifact for deployment
run: unzip release.zip
- name: "Deploy to Azure Web App"
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: "ui-cotopaxi"
slot-name: "Production"
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_04E01406E55D4F78B667E49B87D27787 }}
package: ./dist/vantage6-UI