diff --git a/.github/workflows/.deploy.yml b/.github/workflows/.deploy.yml index d7cecdc97..89a2c5482 100644 --- a/.github/workflows/.deploy.yml +++ b/.github/workflows/.deploy.yml @@ -4,8 +4,13 @@ on: workflow_call: inputs: ### Required + tag: + description: GitHub package tag; e.g. PR number or PROD + required: false + type: string + target: - description: PR number, test or prod + description: Deployment target; e.g. PR number, test or prod required: true type: string @@ -15,8 +20,8 @@ on: required: false type: string - tag: - description: GitHub package tag; omit for PRs + parameters: + description: Template parameters/variables to pass (e.g. -p ZONE=...) required: false type: string @@ -36,31 +41,8 @@ env: JOB_JOB: ${{ github.event.repository.name }}-${{ inputs.target }}-sync-${{ github.run_number }} jobs: - vars: - name: Set Variables - outputs: - tag: ${{ steps.vars.outputs.tag }} - runs-on: ubuntu-latest - steps: - # Get PR number for squash merges to main - - name: PR Number - id: pr - uses: bcgov-nr/action-get-pr@v0.0.1 - - - name: Set Variables - id: vars - run: | - if [ -z "${{ inputs.tag }}" ]; then - echo "No tag provided, using most recent PR merge number." - echo "tag=${{ steps.pr.outputs.pr }}" >> $GITHUB_ENV - else - echo "Tag provided and being used for deployment." - echo "tag=${{ inputs.tag }}" >> $GITHUB_ENV - fi - deploy: - name: Deploy and Run Job - needs: [vars] + name: Deploy environment: ${{ inputs.environment }} runs-on: ubuntu-latest steps: @@ -73,7 +55,9 @@ jobs: oc_token: ${{ secrets.OC_TOKEN }} oc_version: 4.13 overwrite: true - parameters: -p ZONE=${{ inputs.target }} -p TAG=${{ needs.vars.outputs.tag }} + parameters: + -p ZONE=${{ inputs.target }} -p TAG=${{ inputs.tag }} + ${{ inputs.parameters}} post_rollout: oc create job ${{ env.JOB_JOB }} --from=cronjob/${{ env.CRONJOB }} triggers: ${{ inputs.triggers }} diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 8a74603d6..eda3904dc 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -21,12 +21,26 @@ concurrency: cancel-in-progress: false jobs: + vars: + name: Set Variables + outputs: + pr: ${{ steps.pr.outputs.pr }} + runs-on: ubuntu-22.04 + timeout-minutes: 1 + steps: + # Get PR number for squash merges to main + - name: PR Number + id: pr + uses: bcgov-nr/action-get-pr@v0.0.1 + deploy: name: Deploy and Run Job + needs: [vars] secrets: inherit uses: ./.github/workflows/.deploy.yml with: environment: test + tag: ${{ needs.vars.outputs.pr }} target: test verify: false diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index bd5f9ba70..4c1a2ae4a 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -13,11 +13,14 @@ jobs: build: name: Build runs-on: ubuntu-22.04 + outputs: + digest: ${{ steps.build.outputs.digest }} permissions: packages: write timeout-minutes: 10 steps: - uses: bcgov-nr/action-builder-ghcr@v2.0.2 + id: build with: keep_versions: 50 package: sync @@ -26,12 +29,14 @@ jobs: triggers: ('sync/') deploy: - name: Deploy and Run Job + name: Deploy if: needs.build.outputs.digest != '' needs: [build] secrets: inherit uses: ./.github/workflows/.deploy.yml with: + parameters: -p TEST_MODE=1 + tag: ${{ github.event.number }} target: ${{ github.event.number }} results: diff --git a/sync/Dockerfile b/sync/Dockerfile index 30143075e..2e95b788b 100644 --- a/sync/Dockerfile +++ b/sync/Dockerfile @@ -5,8 +5,11 @@ RUN apt update && \ apt install -y --no-install-recommends gcc libpq-dev python3-dev # Disable cache dir, disable upgrade message, create .venv in project dir -ARG PIP_NO_CACHE_DIR=off \ - PIP_DISABLE_PIP_VERSION_CHECK=on +ARG PIP_NO_CACHE_DIR="off" \ + PIP_DISABLE_PIP_VERSION_CHECK="on" \ + PIP_DEFAULT_TIMEOUT="100" \ + PYTHONDONTWRITEBYTECODE="1" \ + PYTHONUNBUFFERED="1" # Copy files and install requirements WORKDIR /app diff --git a/sync/openshift.etl.yml b/sync/openshift.etl.yml index 42a5e8388..f4c97135e 100644 --- a/sync/openshift.etl.yml +++ b/sync/openshift.etl.yml @@ -19,6 +19,9 @@ parameters: - name: REPO description: Repository name value: nr-spar-data + - name: TEST_MODE + description: "Run in test mode" + value: "1" ### Usually a bad idea - not recommended - name: CRON_MINUTES @@ -67,7 +70,9 @@ objects: containers: - name: ${REPO}-${ZONE} image: "${REGISTRY}/${ORG}/${REPO}/${APP}:${TAG}" - # env: + env: + - name: test_mode + value: "${TEST_MODE}" # - name: POSTGRES_SERVICE # value: "${REPO}-${ZONE}-database" resources: