feat: add lean alpine image with psql client #275
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR | |
on: | |
pull_request: | |
branches: [main] | |
concurrency: | |
# PR open and close use the same group, allowing only one at a time | |
group: pr-${{ github.workflow }}-${{ github.event.number }} | |
cancel-in-progress: true | |
jobs: | |
checks: | |
name: Dockerfile Checks | |
runs-on: ubuntu-24.04 | |
outputs: | |
json: ${{ steps.dockerfiles.outputs.json }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Dockerfiles | |
id: dockerfiles | |
run: | | |
# Fetch default_branch (usually main) | |
git fetch origin ${{ github.event.repository.default_branch }} | |
# Get changed Dockerfiles, create JSON object for the builder | |
DOCKERFILES=($(git diff --name-only origin/${{ github.event.repository.default_branch }} | grep -E '^.*/.*/Dockerfile$' | sort -u)) | |
LIST=$( | |
for d in "${DOCKERFILES[@]}"; do | |
BASE=${d%/*} | |
echo "{\"package\": \"${BASE%/*}\", \"major_tag\": \"${BASE##*/}\"}," | |
done | |
) | |
# Clip any trailing commas | |
JSON=$(echo [$LIST] | sed 's/\(.*\),/\1/') | |
# Send to output if non-empty | |
echo "json=${JSON}" | |
if [ "${#JSON}" -gt 4 ] | |
then | |
echo "json=${JSON}" >> $GITHUB_OUTPUT | |
fi | |
# https://github.com/bcgov-nr/action-builder-ghcr | |
builds: | |
name: Builds | |
needs: [checks] | |
if: ${{ needs.checks.outputs.json }} | |
permissions: | |
packages: write | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
include: ${{ fromJSON(needs.checks.outputs.json) }} | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get tag | |
id: tag | |
run: | | |
TAG=$(grep '^FROM' ${{ matrix.package }}/${{ matrix.major_tag }}/Dockerfile | cut -d':' -f2) | |
echo "full_tag=${TAG}" >> $GITHUB_OUTPUT | |
- name: Build or import | |
uses: bcgov-nr/[email protected] | |
with: | |
build_context: ${{ matrix.package }}/${{ matrix.major_tag }} | |
package: ${{ matrix.package }} | |
tag: ${{ steps.tag.outputs.full_tag }} | |
results: | |
name: PR Results | |
needs: [checks, builds] | |
if: always() && (!failure()) && (!cancelled()) | |
runs-on: ubuntu-24.04 | |
permissions: | |
pull-requests: write | |
timeout-minutes: 1 | |
steps: | |
- uses: bcgov-nr/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
add_markdown: | | |
--- | |
Thanks for the PR! Our PR workflow has completed successfully. :) | |
Any new images should be viewable with [our repo packages](https://github.com/orgs/bcgov/packages?repo_name=nr-containers). |