Skip to content

Commit

Permalink
Merge pull request #15 from KineticCafe/rethink-image-release-strategy
Browse files Browse the repository at this point in the history
Rethink Image Strategy
  • Loading branch information
halostatue authored Mar 27, 2023
2 parents aa614d7 + e95e09f commit 4921a9c
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,42 +1,17 @@
name: Build and Publish Image
name: Build Test Image

on:
# push:
# branches:
# - 'main'
# tags:
# - 'v*.*.*'
pull_request:
branches:
- 'main'
workflow_call:

jobs:
build:
name: Build and Push to Docker Hub
name: Build Test Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
if: >-
github.event_name == 'workflow_call' ||
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
if: >-
github.event_name == 'workflow_call' ||
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: meta
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0
with:
Expand All @@ -62,12 +37,8 @@ jobs:
- id: docker_build
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
with:
push: >-
${{
github.event_name == 'workflow_call' ||
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch'
}}
context: .
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
Expand All @@ -80,16 +51,3 @@ jobs:
linux/arm/v7
cache-from: type=gha
cache-to: type=gha,mode=max

- uses: peter-evans/dockerhub-description@202973a37c8a723405c0c5f0a71b6d99db470dae # v3.3.0
if: >-
github.event_name == 'workflow_call' ||
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch'
with:
repository: kineticcafe/sqitch-pgtap
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
72 changes: 70 additions & 2 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish release
name: Create Release and Push to Container Registries

on:
push:
Expand All @@ -25,4 +25,72 @@ jobs:
with:
summaryEnabled: false
publish-image:
uses: ./.github/workflows/build-and-push.yml
name: Build and Push to Docker Hub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
if: github.event_name == 'push'
- uses: actions/checkout@v3
if: github.event_name == 'workflow_dispatch'
with:
ref: refs/tags/${{ github.event.inputs.tag }}

- uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: meta
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0
with:
images: |
kineticcafe/sqitch-pgtap
ghcr.io/kineticcafe/sqitch-pgtap
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0
- uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2.5.0

- id: package-versions
run: echo "data=$(cat package-versions.json)" >> $GITHUB_OUTPUT

- id: docker_build
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
PG_PROVE_VERSION=${{ fromJSON(steps.package-versions.outputs.data).pg_prove.version }}
PGTAP_VERSION=${{ fromJSON(steps.package-versions.outputs.data).pgtap.version }}
SQITCH_VERSION=${{ fromJSON(steps.package-versions.outputs.data).sqitch.version }}
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
cache-from: type=gha
cache-to: type=gha,mode=max

- uses: peter-evans/dockerhub-description@202973a37c8a723405c0c5f0a71b6d99db470dae # v3.3.0
with:
repository: kineticcafe/sqitch-pgtap
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

0 comments on commit 4921a9c

Please sign in to comment.