Skip to content

Commit

Permalink
PR workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekRoberts committed Dec 6, 2023
1 parent e6ef343 commit 56d6256
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 79 deletions.
49 changes: 6 additions & 43 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,16 @@ concurrency:
cancel-in-progress: true

jobs:
# QuickStart apps build from the same dirs as their Dockerfiles
build:
permissions:
packages: write
name: Build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./
with:
package: backend
keep_versions: 10
repository: bcgov/quickstart-openshift
tag: ${{ github.event.number }}

# Anything can be retagged if a fallback image exists (e.g. test)
retag:
test:
needs: [build]
permissions:
packages: write
name: Retag
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./
with:
package: backend
keep_versions: 10
repository: bcgov/quickstart-openshift
tag: ${{ github.event.number }}-retag
tag_fallback: test
triggers: ('backend/')


# FOM apps build from repo root, above their Dockerfiles (extra params)
advanced:
permissions:
packages: write
name: Advanced
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./
with:
package: api
build_context: .
build_file: api/Dockerfile
keep_versions: 10
repository: bcgov/nr-fom
tag: ${{ github.event.number }}
- id: vars
uses: ./

- name: Echo PR number
run: echo "PR: ${{ steps.vars.outputs.pr }}"
42 changes: 6 additions & 36 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,26 @@ branding:

inputs:
### Required
package:
description: Package name; e.g. backend, frontend
required: true
tag:
description: Default tag; e.g. pr#, test, prod
required: true
# Nothing!

### Typical / recommended
tag_fallback:
description: Where to pull default images from; e.g. prod, test
triggers:
description: Paths used to trigger a build; e.g. ('./backend/' './frontend/)
build_context:
description: Build context, not required for self-contained package/default directory
build_file:
description: Dockerfile with path, not required for self-contained package/default directory
keep_versions:
description: Number of versions to keep; omit to skip
# Nothing!

### Usually a bad idea / not recommended
build_args:
description: A list of build-time variables, generally not adviseable
value: "BUILDKIT_INLINE_CACHE=1"
diff_branch:
description: Branch to diff against
default: ${{ github.event.repository.default_branch }}
keep_regex:
description: Regex for tags to skip when keep_versions is provided; defaults to test and prod
default: "^(prod|test|latest)$"
repository:
description: Non-default repo to clone
default: ${{ github.repository }}
token:
description: Specify token (GH or PAT), instead of inheriting one from the calling workflow
default: ${{ github.token }}

outputs:
digest:
description: 'Digest of the built image. for ex: sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
value: ${{ steps.get_digest.outputs.digest }}
pr:
description: 'Associated pull request number'
value: ${{ steps.vars.outputs.pr }}

runs:
using: composite
steps:
- uses: actions/checkout@v4
with:
# Check out build repo
repository: ${{ inputs.repository }}

# Process variables and inputs
- uses: actions/checkout@v4
- id: vars
shell: bash
run: |
Expand Down

0 comments on commit 56d6256

Please sign in to comment.