This repository has been archived by the owner on Mar 19, 2024. It is now read-only.
Add loading spinner to start component #33
Workflow file for this run
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
# 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/[email protected] | |
# 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 | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get branch on which the tag is based | |
id: branchname | |
run: | | |
# get the branch on which the tag is based | |
raw=$(git branch -r --contains ${{ github.ref }}) | |
# delete the name of the branch up to and including 'origin/' | |
branch=$(echo $raw | sed 's/.*origin\///') | |
echo "branch=${branch}" >> $GITHUB_OUTPUT | |
- name: Checkout branch on which tag was pushed | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ env.branch }} | |
token: ${{ secrets.COMMIT_PAT }} | |
- name: Update UI version in package.json | |
env: | |
version: ${{ steps.split.outputs.version }} | |
run: | | |
npm version --no-git-tag-version --allow-same-version $version | |
- name: Commit updated version | |
env: | |
version: ${{ steps.split.outputs.version }} | |
branch: ${{ steps.branchname.outputs.branch }} | |
run: | | |
git config --local user.name github-actions | |
git config --local user.email [email protected] | |
git add * | |
git commit -m "Updated the version to ${version}" | |
git push origin HEAD:$branch | |
outputs: | |
version: ${{ steps.split.outputs.version }} | |
stage: ${{ steps.split.outputs.stage }} | |
major_name: ${{ steps.split.outputs.major_name }} | |
branch: ${{ steps.branchname.outputs.branch }} | |
# Build artifact for deployment | |
build: | |
name: Build deployment artifact | |
runs-on: ubuntu-latest | |
needs: version | |
env: | |
version: ${{ needs.version.outputs.version }} | |
branch: ${{ needs.version.outputs.branch }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{env.branch}} | |
- name: Set up Node.js version | |
uses: actions/setup-node@v1 | |
with: | |
node-version: "20.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 | |
# TODO this should be moved to a separate workflow so build and deployment are separated | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [version, build] | |
env: | |
stage: ${{ needs.version.outputs.stage }} | |
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" | |
if: ${{ env.stage == '' }} | |
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 |