chore(deps): update github actions all dependencies (major) #113
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: PR Open | |
on: | |
# used on push for testing / development | |
# --------------------------------------------------------- | |
# push: | |
# branches: ['master', 'main', 'feat/5-deploy-frontend'] | |
pull_request: | |
# debug: remove the dev,putting build action on non existent branches for debug | |
branches: ['main'] | |
types: ['opened', 'reopened', 'edited', 'synchronize'] | |
paths-ignore: | |
- .vscode/** | |
- .gitignore | |
- LICENSE | |
- readme.md | |
- code_of_conduct.md | |
- scripts/** | |
- .flake8 | |
- COMPLIANCE.yaml | |
- docs/** | |
workflow_dispatch: | |
jobs: | |
# calculate the image tag / used to tag image and then for the | |
# deployment | |
CalculateImageTags: | |
defaults: | |
run: | |
shell: bash | |
name: calculateImageTag | |
runs-on: ubuntu-24.04 | |
outputs: | |
imagetag: ${{ steps.CalculateImageTagstep.outputs.IMAGE_TAG}} | |
steps: | |
- name: Calculate Image Tag | |
id: CalculateImageTagstep | |
shell: bash | |
run: | | |
DATESTAMP=$(date +%Y%m%d-%H%M) | |
echo datestamp is $DATESTAMP | |
echo event number: ${{ github.event.number }} | |
echo "IMAGE_TAG=${DATESTAMP}" >> "$GITHUB_OUTPUT" | |
BuildContainerImage: | |
defaults: | |
run: | |
shell: bash | |
needs: CalculateImageTags | |
name: 'Build Listener Container Image' | |
runs-on: ubuntu-24.04 | |
env: | |
DEBUG_DEPLOY: false | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v4 | |
id: checkout | |
- name: Verify tag | |
id: CalculateImageTagstep | |
shell: bash | |
env: | |
IMAGE_TAG: ${{ needs.CalculateImageTags.outputs.imagetag }} | |
run: | | |
echo image tag is $IMAGE_TAG ${{ env.IMAGE_TAG }} | |
echo event number is: ${{ github.event.number }} | |
- name: Log in to GitHub Docker Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push Client Docker Image | |
uses: docker/build-push-action@v6 | |
env: | |
IMAGE_TAG: ${{ needs.CalculateImageTags.outputs.imagetag }} | |
with: | |
push: true # Will only build if this is not here | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/datamart_listener:latest | |
ghcr.io/${{ github.repository_owner }}/datamart_listener:${{ env.IMAGE_TAG }} | |
ghcr.io/${{ github.repository_owner }}/datamart_listener:pr-${{ github.event.number }} | |
# This workflow contains a single job called "build" | |
DeployJob: | |
defaults: | |
run: | |
shell: bash | |
needs: [CalculateImageTags, BuildContainerImage] | |
name: 'Deploy AMQP Listener Image' | |
runs-on: ubuntu-24.04 | |
environment: dev | |
steps: | |
- uses: actions/checkout@v4 | |
id: checkout | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Log in and set context | |
uses: redhat-actions/oc-login@v1 | |
with: | |
openshift_server_url: ${{ vars.OC_SERVER }} | |
openshift_token: ${{ secrets.OC_TOKEN }} | |
namespace: ${{ vars.OC_NAMESPACE }} | |
- name: Calculate Zone | |
id: calculateZone | |
shell: bash | |
run: | | |
event_num=${{ github.event.number }} | |
if [[ -z "${event_num// }" ]]; then | |
zone=pr-999 | |
else | |
zone=pr-$event_num | |
fi | |
echo zone: $zone | |
echo "ZONE=$zone" >> $GITHUB_ENV | |
- name: Run Helm Chart | |
id: runHelmChart | |
shell: bash | |
env: | |
IMAGE_TAG: ${{ needs.CalculateImageTags.outputs.imagetag }} | |
ACCESS_TOKEN: ${{ secrets.CMC_TOKEN }} | |
run: | | |
cd cicd | |
ls -la | |
# helm upgrade --install message-queue message-queue \ | |
helm upgrade --install message-queue-${{ env.ZONE }} message-queue \ | |
--set image.image_tag=${{ env.IMAGE_TAG }} \ | |
--set image.promote=bcgov/datamart_listener:${{ env.IMAGE_TAG }} \ | |
--set app.zone=${{ env.ZONE }} \ | |
--set github_secrets.access_token=${{ env.ACCESS_TOKEN }} | |
#docker pull ghcr.io/bcgov/datamart_listener:20230621-0332 | |
- name: Get Route URL | |
id: getRouteUrl | |
shell: bash | |
run: | | |
# retrieve the route url | |
# --------------------------------------------------------- | |
app_name=$(cat ./cicd/message-queue/values.yaml | yq e '.app.name') | |
app_comp=$(cat ./cicd/message-queue/values.yaml | yq e '.app.component') | |
route_name=$app_name-${{ env.ZONE }}-$app_comp | |
route_path=$(oc get route $route_name -o json | jq .spec.host | tr -d '"' ) | |
echo "OC_ROUTE=https://$route_path" >> $GITHUB_ENV | |
- name: Comment PR | |
uses: thollander/actions-comment-pull-request@v3 | |
with: | |
message: | | |
Route to deployed app is: ${{ env.OC_ROUTE }}/docs |