[UPDATED]-API calls updated with --qos #325
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
name: build | |
# The workflow will run when a tag matching the pattern 'v*.*.*' is pushed to the repository | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest #build job runs on the latest ubuntu version | |
steps: | |
- uses: actions/checkout@v3 #checkout the repositories's code | |
with: | |
fetch-depth: 0 #fetch the entire history of repository, including all commits and tags | |
node-version: 16 | |
# Work around https://github.com/actions/checkout/issues/290, this will fetch all the tags in the repository | |
- run: git fetch --force --tags | |
#Sets up a Node.js environment on the runner | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
#Caches dependencies to speed up future builds | |
- uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
#Install the project's Node.js dependencies | |
- run: npm install | |
- run: mkdir artifacts | |
- name: create tarball #create .tar.gz containing project files,excluding artifacts folder and .git | |
run: | | |
GIT_DESCRIBE=$(git describe) | |
sed -i -e "s/%GIT_DESCRIBE%/$(git describe)/g" ./public/index.html | |
tar -czf artifacts/imbportal-${GIT_DESCRIBE}.tar.gz \ | |
--transform "s/^\./imbportal-${GIT_DESCRIBE}/" \ | |
--exclude=./artifacts \ | |
--exclude=./.git \ | |
. | |
# uploads the tarball created in the previous step as an artifact, making it available for download in later steps or jobs | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: release-artifacts | |
path: artifacts/imbportal-*.tar.gz | |
# ---- This section is to create docker image and pushing to harbor--- | |
# Sets up Docker Buildx, a tool that allows for advanced Docker image building, including multi-platform support | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
#caches doker layers to speed up future builds | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-docker-cache-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-docker-cache- | |
#logs into harbor registry | |
- name: Log in to Harbor | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ secrets.HARBOR_REGISTRY }} | |
username: ${{ secrets.HARBOR_USERNAME }} | |
password: ${{ secrets.HARBOR_PASSWORD }} | |
#Extracts the version number of the tag | |
- name: Extract tag | |
id: extract_tag | |
run: echo "TAG=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
# Builds a docker image and pushes it to harbor | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: ${{ secrets.HARBOR_REGISTRY }}/rcc-portals-a/apps-ipp:${{env.TAG}} | |
# ---end creating docker image and pushing to harbor --- | |
# Deploy job depends on the build job, deploy job will only run if event is a push, the ref starts with refs/tags/, and the tag name is master | |
deploy: | |
needs: build | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && github.ref_name == 'master' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: release-artifacts | |
path: dist | |
- uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
files: dist/* | |