diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..9cc5fa9 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,84 @@ +name: Build & Push OCI Image to OCI Image Registry + +on: + workflow_call: + inputs: + workdirs: + required: true + type: string + images: + required: true + type: string + secrets: + ghcr-username: + required: true + ghcr-access-token: + required: true + +permissions: + contents: read + packages: write + +jobs: + build: + continue-on-error: true + strategy: + matrix: # REFS: https://github.community/t/reusable-workflow-with-strategy-matrix/205676 + workdir: ${{ fromJSON(inputs.workdirs) }} + + runs-on: ubuntu-latest + + steps: + - name: Check Out Repository + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - name: Set up QEMU for Docker Buildx + uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2.2.0 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2.10.0 + + - name: Set up Node.js for extracting recipe from Dockerfile + uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2 + + - name: Extract recipe from Dockerfile + id: recipe + run: | + TAGS=`npm exec -sy @hazmi35/extract-docker-baseimg-recipe ${{ matrix.workdir }}/Dockerfile tags` + PLATFORMS=`npm exec -sy @hazmi35/extract-docker-baseimg-recipe ${{ matrix.workdir }}/Dockerfile platforms` + VARIANT=`npm exec -sy @hazmi35/extract-docker-baseimg-recipe ${{ matrix.workdir }}/Dockerfile variant` + echo TAGS: $TAGS + echo PLATFORMS: $PLATFORMS + echo VARIANT: $VARIANT + echo "::set-output name=tags::${TAGS//$', '/'%0A'}" + echo "::set-output name=platforms::${PLATFORMS//$', '/'%0A'}" + echo "::set-output name=variant::$VARIANT" + + - name: Generate Docker image metadata + uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 # v4.6.0 + id: meta + with: + images: ${{ inputs.images }} + tags: | + ${{ steps.recipe.outputs.tags }} + + - name: Login to GitHub Container Registry + if: ${{ github.event_name != 'pull_request' }} + uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0 + with: + registry: ghcr.io + username: ${{ secrets.ghcr-username }} + password: ${{ secrets.ghcr-access-token }} + + - name: Build and push the Docker image from the specified Dockerfile + id: docker_build + uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3.3.1 + with: + context: . + file: ./${{ matrix.workdir }}/Dockerfile + platforms: | + ${{ steps.recipe.outputs.platforms }} + push: ${{ github.event_name == 'push' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/postgres-16.yaml b/.github/workflows/postgres-16.yaml new file mode 100644 index 0000000..a865f86 --- /dev/null +++ b/.github/workflows/postgres-16.yaml @@ -0,0 +1,30 @@ +name: Build & Push Postgres 16 OCI Image to OCI Image Registry + +on: + push: + branches: + - main + paths: + - "16/Dockerfile" + pull_request: + branches: + - main + paths: + - "16/Dockerfile" + +jobs: + workdirs: + uses: ./.github/workflows/specify-workdir.yaml + with: + base-dir: 18 + + image: + uses: ./.github/workflows/build.yaml + needs: workdirs + with: + workdirs: '["16"]' + images: | + ghcr.io/takodotid/postgres + secrets: + ghcr-username: ${{ github.repository_owner }} + ghcr-access-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile b/16/Dockerfile similarity index 100% rename from Dockerfile rename to 16/Dockerfile