Skip to content

Commit

Permalink
Consistency and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekRoberts committed Jan 18, 2024
1 parent 881394e commit eaa089b
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 21 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,13 @@ jobs:
cypress-e2e:
name: Cypress end to end test
needs:
- deploys
needs: [deploys]
runs-on: ubuntu-22.04
strategy:
matrix:
browser: [ chrome, firefox, edge ]
steps:
- uses: actions/checkout@v4
name: Checkout
- uses: cypress-io/github-action@v5
name: Cypress run
with:
Expand All @@ -116,6 +114,7 @@ jobs:
name: cypress-screenshots
path: ./frontend/cypress/screenshots
if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`

deploys-prod:
name: PROD Deployments
needs: [semantic-version,cypress-e2e]
Expand Down
21 changes: 5 additions & 16 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ jobs:
strategy:
matrix:
package: [api, frontend, database]
include:
- package: frontend
triggers: ('frontend/')
- package: api
triggers: ('api/')
- package: database
triggers: ('database/')

steps:
- uses: actions/checkout@v4
- uses: bcgov-nr/action-builder-ghcr@v2.0.1
Expand All @@ -58,7 +50,7 @@ jobs:
tag: ${{ github.sha }}
tag_fallback: test
token: ${{ secrets.GITHUB_TOKEN }}
triggers: ${{ matrix.triggers }}
triggers: ('${{ matrix.package }}/')

- uses: shrink/actions-docker-registry-tag@v3
with:
Expand All @@ -77,12 +69,11 @@ jobs:
- name: Deploy to OpenShift
shell: bash
run: |
# Allow pipefail, since we could be catching oc create errors
# Expand for deployment steps
set +o pipefail
# Login to OpenShift (NOTE: project command is a safeguard)
oc login --token=${{ secrets.oc_token }} --server=${{ vars.oc_server }}
oc project ${{ vars.oc_namespace }}
oc project ${{ vars.oc_namespace }} # Safeguard!

# Deploy Helm Chart
cd charts/pubcode
Expand Down Expand Up @@ -123,15 +114,13 @@ jobs:

cypress-e2e:
name: Cypress end to end test
needs:
- deploys
needs: [deploys]
runs-on: ubuntu-22.04
strategy:
matrix:
browser: [ chrome, edge ]
browser: [chrome, edge]
steps:
- uses: actions/checkout@v4
name: Checkout
- uses: cypress-io/github-action@v5
name: Cypress run
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/schedule-jobs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Schedule Jobs
name: Scheduled

on:
workflow_dispatch:
Expand All @@ -10,7 +10,7 @@ on:
- cron: "0 8 * * *"

concurrency:
group: ${{ github.workflow }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Expand Down
96 changes: 96 additions & 0 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
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@v3
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@v3
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."

0 comments on commit eaa089b

Please sign in to comment.