Skip to content

Schedule Jobs

Schedule Jobs #249

Workflow file for this run

name: Schedule Jobs
on:
workflow_dispatch:
inputs:
REPO_NAMES:
required: false
description: comma separated list of repo names within bcgov org. for one of jobs to run for specific repos.
schedule: # * is a special character in YAML, so you have to quote this string, every day at 8am GMT
- cron: "0 8 * * *"
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
pubcode-crawler:
name: Crawl Git Repos for bcgovpubcode.yml
runs-on: ubuntu-22.04
environment: prod
defaults:
run:
working-directory: crawler
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Add Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Install Dependencies
run: npm ci
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Process script
env:
GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_NAMES: ${{ github.event.inputs.REPO_NAMES }}
run: |
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ vars.OC_SERVER }}
oc project ${{ vars.OC_NAMESPACE }}
# Get API key
API_KEY=$(oc get secrets/pubcode --template={{.data.API_KEY}} | base64 -d)
API_URL=https://$(oc get route/pubcode-api --template={{.spec.host}})
API_KEY="${API_KEY}" API_URL="${API_URL}" node src/main.js
validate-ministry-list:
name: Validate Ministry List in the pubcode schema.
runs-on: ubuntu-22.04
defaults:
run:
working-directory: schema/script
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Add Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Install Dependencies
run: npm ci
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Process script
id: validate-ministry-list
run: node ./index.js
- name: create a branch, commit and push changes
if: steps.validate-ministry-list.outputs.schemaChanged == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
git config --local user.name ${{ github.actor }}
git checkout -b chore/ministry-name-schema
git add ../bcgovpubcode.json
git commit -m "Updating the Schema as changes to ministry names were detected."
git push origin chore/ministry-name-schema
# Create a Pull Request
gh pr create --assignee "mishraomp" --base main --label "chore" --title "Updating the Schema as changes to ministry names were detected." --body "Updating the Schema as changes to ministry names were detected."
soft-delete-removed-pubcodes:
name: Soft Delete pubcodes In the Databse which are removed from the repo.
runs-on: ubuntu-22.04
defaults:
run:
working-directory: utilities/remove-deleted-pubcode
environment: prod
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Add Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Install Dependencies
run: npm ci
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Process script
run: |
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ vars.OC_SERVER }}
oc project ${{ vars.OC_NAMESPACE }}
# Get API key
API_KEY=$(oc get secrets/pubcode --template={{.data.API_KEY}} | base64 -d)
API_URL=https://$(oc get route/pubcode-api --template={{.spec.host}})
API_KEY="${API_KEY}" API_URL="${API_URL}" node index.js