Skip to content

Commit

Permalink
chore(ci): build_number var in sync (#1502)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekRoberts authored Aug 15, 2024
1 parent 670c327 commit d9f287c
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
23 changes: 1 addition & 22 deletions .github/workflows/.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,4 @@ jobs:

- name: Run sync ETL
if: github.event_name == 'pull_request'
run: |
# Run and verify job
# Login
oc login --token=${{ secrets.oc_token }} --server=${{ vars.oc_server }}
oc project ${{ secrets.oc_namespace }} #Safeguard!
# Exit on errors or unset variables
set -eu
# Create job
CRONJOB=nr-spar-${{ inputs.target }}-sync
RUN_JOB=${CRONJOB}--$(date +"%Y-%m-%d--%H-%M-%S")
oc create job ${RUN_JOB} --from=cronjob/${CRONJOB}
# Follow
oc wait --for=condition=ready pod --selector=job-name=${RUN_JOB} --timeout=1m
oc logs -l job-name=${RUN_JOB} --tail=50 --follow
# Verify successful completion
oc wait --for jsonpath='{.status.phase}'=Succeeded pod --selector=job-name=${RUN_JOB} --timeout=1m
echo "Job successful!"
run: ./sync/oc_run.sh ${{ secrets.oc_token }}
2 changes: 1 addition & 1 deletion .github/workflows/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
# Login
oc login --token=${{ secrets.oc_token }} --server=${{ vars.oc_server }}
oc project ${{ secrets.oc_namespace }} #Safeguard!
oc project ${{ vars.oc_namespace }} #Safeguard!
# Delete and replace route
oc delete route/${{ env.REPO }}-${{ env.DEST }} --ignore-not-found=true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/job-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
# Login
oc login --token=${{ secrets.oc_token }} --server=${{ vars.oc_server }}
oc project ${{ secrets.oc_namespace }} #Safeguard!
oc project ${{ vars.oc_namespace }} #Safeguard!
# Exit on errors or unset variables
set -eu
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
id: build
with:
build_args: |
"BUILDKIT_INLINE_CACHE=1"
--build-arg BUILD_NUMBER=${{ github.event.number }}
BUILD_NUMBER=${{ github.event.number }}
BUILDKIT_INLINE_CACHE=1
package: ${{ matrix.package }}
tag: ${{ github.event.number }}
tag_fallback: latest
Expand Down
2 changes: 1 addition & 1 deletion sync/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.12-slim

# Receive build number as argument, retain as environment variable
ARG BUILD_NUMBER=0
ARG BUILD_NUMBER
ENV BUILD_NUMBER=${BUILD_NUMBER}

# Packages and nonroot user
Expand Down
25 changes: 25 additions & 0 deletions sync/oc_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
#
# Exit on errors or unset variables
set -eux

# Run and verify job

# Login
if [ ! -z "${1:-}" ]; then
oc login --token=${1} --server=https://api.silver.devops.gov.bc.ca:6443
oc project #Safeguard!
fi

# Create job
CRONJOB=nr-spar-1502-sync
RUN_JOB=${CRONJOB}--$(date +"%Y-%m-%d--%H-%M-%S")
oc create job ${RUN_JOB} --from=cronjob/${CRONJOB}

# Follow
oc wait --for=condition=ready pod --selector=job-name=${RUN_JOB} --timeout=1m
oc logs -l job-name=${RUN_JOB} --tail=50 --follow

# Verify successful completion
oc wait --for jsonpath='{.status.phase}'=Succeeded pod --selector=job-name=${RUN_JOB} --timeout=1m
echo "Job successful!"
4 changes: 0 additions & 4 deletions sync/openshift.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ parameters:
value: "false"

### Usually a bad idea - not recommended
- name: CRON_MINUTES
description: Random number, 0-60, for scheduling cronjobs
from: "[0-5]{1}[0-9]{1}"
generate: expression
- name: JOB_BACKOFF_LIMIT
description: "The number of attempts to try for a successful job outcome"
value: "3"
Expand Down

0 comments on commit d9f287c

Please sign in to comment.