Skip to content

Commit

Permalink
feat: parameters, cleanup and codeowners (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekRoberts authored Oct 6, 2023
1 parent 46f03b9 commit f716b05
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
7 changes: 7 additions & 0 deletions .github/codeowners
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Matched against repo root (asterisk)
* @mishraomp @paulushcgcj @DerekRoberts

# Matched against directories
# /.github/workflows/ @mishraomp @paulushcgcj @DerekRoberts

# See https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
2 changes: 1 addition & 1 deletion .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
package: [test-basic, test-advanced]
package: [api, backend]
steps:
- uses: shrink/actions-docker-registry-tag@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Only GitHub Container Registry (ghcr.io) is supported so far.
build_context: ./frontend

# Sets the Dockerfile with path
# Optional, defaults to the package name's folder
# Optional, defaults to {package}/Dockerfile or {build_context}/Dockerfile
build_file: ./frontend/Dockerfile

# Number of packages to keep if cleaning up previous builds
Expand Down
30 changes: 14 additions & 16 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ inputs:
### 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 }}
Expand Down Expand Up @@ -62,24 +63,19 @@ runs:
# Use package folder as build_context unless an override has been provided
if [ -z ${{ inputs.build_context }} ]; then
echo "build_context=${{ inputs.package }}" >> $GITHUB_OUTPUT
BUILD_CONTEXT=${{ inputs.package }}
else
echo "build_context=${{ inputs.build_context }}" >> $GITHUB_OUTPUT
BUILD_CONTEXT=${{ inputs.build_context }}
fi
echo "build_context=${BUILD_CONTEXT}" >> $GITHUB_OUTPUT
# Use inputs.package/Dockerfile as build_file unless an override has been provided
# Use BUILD_CONTEXT/Dockerfile as build_file unless an override has been provided
if [ -z ${{ inputs.build_file }} ]; then
echo "build_file=${{ inputs.package }}/Dockerfile" >> $GITHUB_OUTPUT
BUILD_FILE=${BUILD_CONTEXT}/Dockerfile
else
echo "build_file=${{ inputs.build_file }}" >> $GITHUB_OUTPUT
fi
# Use inputs.build_args unless an override has been provided
if [ -z ${{ inputs.build_args }} ]; then
echo "build_arguments=BUILDKIT_INLINE_CACHE=1" >> $GITHUB_OUTPUT
else
echo "build_arguments=${{ inputs.build_args }}" >> $GITHUB_OUTPUT
BUILD_FILE=${{ inputs.build_file }}
fi
echo "build_file=${BUILD_FILE}" >> $GITHUB_OUTPUT
# Bug - Docker build hates images with capital letters
TAGS=$( echo "ghcr.io/${{ github.repository }}/${{ inputs.package }}:${{ inputs.tag }}" | tr '[:upper:]' '[:lower:]' )
Expand Down Expand Up @@ -147,7 +143,7 @@ runs:
target: ${{ inputs.tag_fallback }}
tags: ${{ inputs.tag }}

# If a build is required, then build and push!
# If a build is required, then login, build and push!
- name: Set up Docker Buildx
if: steps.build.outputs.triggered == 'true'
uses: docker/setup-buildx-action@v3
Expand All @@ -170,9 +166,9 @@ runs:
tags: ${{ steps.vars.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: ${{ steps.vars.outputs.build_arguments }}
provenance: false
build-args: ${{ inputs.build_args }}

# Cleanup if inputs.keep_versions provided
- name: GHCR Cleanup
if: ${{ inputs.keep_versions }}
uses: actions/delete-package-versions@v4
Expand All @@ -182,5 +178,7 @@ runs:
min-versions-to-keep: ${{ inputs.keep_versions }}
ignore-versions: "${{ inputs.keep_regex }}"

- name: Checkout Action repo to pass tests
# Action repo needs to be present for cleanup/tests
- name: Checkout local repo to make sure action.yml is present
if: ${{ github.repository }} != ${{ inputs.repository }}
uses: actions/checkout@v4

0 comments on commit f716b05

Please sign in to comment.