Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 37 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- '**.md'
- '.gitignore'
- '.github/workflows/pushrm.yml'
workflow_dispatch:
pull_request:
paths-ignore:
- '**.md'
Expand Down Expand Up @@ -151,6 +152,9 @@ jobs:
needs: [ test-script ]
runs-on: ubuntu-22.04
environment: docker.io
permissions:
contents: read
packages: write
steps:
# Increase available disk space by removing unnecessary tool chains:
# https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
Expand All @@ -165,27 +169,48 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Configure build revision
id: vars
run: echo "sha_short=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT"

- name: Login to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
if: github.repository_owner == 'prodrigestivill'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Configure build revision
id: vars
run: echo "::set-output name=sha_short::${GITHUB_SHA:0:7}"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: github.repository_owner != 'prodrigestivill'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build images
env:
REGISTRY_PREFIX: ${{ secrets.DOCKERHUB_USERNAME }}/
BUILD_REVISION: ${{ steps.vars.outputs.sha_short }}
run: docker buildx bake --pull
- name: Docker meta
id: meta
uses: docker/metadata-action@v5

- name: Get repo name
run: |
echo "REPO_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 2)" >> "$GITHUB_ENV"
echo "GHCR_REPO=ghcr.io/$GITHUB_REPOSITORY_OWNER" >> "$GITHUB_ENV"

- name: Push images
- name: Build image
uses: docker/bake-action@v6
env:
REGISTRY_PREFIX: ${{ secrets.DOCKERHUB_USERNAME }}/
REGISTRY_PREFIX: ${{ github.repository_owner == 'prodrigestivill' && secrets.DOCKERHUB_USERNAME || env.GHCR_REPO }}/
IMAGE_NAME: ${{ github.repository_owner == 'prodrigestivill' && 'postgres-backup-local' || env.REPO_NAME }}
BUILD_REVISION: ${{ steps.vars.outputs.sha_short }}
run: docker buildx bake --push
with:
push: true
targets: default
files: |
./docker-bake.hcl
cwd://${{ steps.meta.outputs.bake-file-labels }}
cwd://${{ steps.meta.outputs.bake-file-annotations }}


## Example of publish using GitHub Container Registry instead
# publish:
Expand Down
14 changes: 13 additions & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
target "docker-metadata-action" {}

group "default" {
targets = ["debian-latest", "alpine-latest", "debian-17", "debian-16", "debian-15", "debian-14", "debian-13", "alpine-17", "alpine-16", "alpine-15", "alpine-14", "alpine-13"]
targets = ["debian-latest", "debian-17", "debian-16", "debian-15", "debian-14", "debian-13", "alpine-latest", "alpine-17", "alpine-16", "alpine-15", "alpine-14", "alpine-13"]
}

group "debian-all" {
targets = ["debian-latest", "debian-17", "debian-16", "debian-15", "debian-14", "debian-13"]
}

group "alpine-all" {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I split them up so I could do faster iteration of testing by just building alpine instead of default
lemme know if you want me to put it back

targets = ["alpine-latest", "alpine-17", "alpine-16", "alpine-15", "alpine-14", "alpine-13"]
}

variable "REGISTRY_PREFIX" {
Expand All @@ -15,11 +25,13 @@ variable "BUILD_REVISION" {
}

target "debian" {
inherits = ["docker-metadata-action"]
args = {"GOCRONVER" = "v0.0.11"}
dockerfile = "debian.Dockerfile"
}

target "alpine" {
inherits = ["docker-metadata-action"]
args = {"GOCRONVER" = "v0.0.11"}
dockerfile = "alpine.Dockerfile"
}
Expand Down
22 changes: 18 additions & 4 deletions generate-docker-bake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@ cd "$(dirname "$0")"

P="\"$(echo $PLATFORMS | sed 's/ /", "/g')\""

T="\"debian-latest\", \"alpine-latest\", \"$(echo debian-$TAGS_EXTRA | sed 's/ /", "debian-/g')\", \"$(echo alpine-$TAGS_EXTRA | sed 's/ /", "alpine-/g')\""
DEBIAN_TARGETS="\"debian-latest\", \"$(echo debian-$TAGS_EXTRA | sed 's/ /", "debian-/g')\""
ALPINE_TARGETS="\"alpine-latest\", \"$(echo alpine-$TAGS_EXTRA | sed 's/ /", "alpine-/g')\""

cat >"$DOCKER_BAKE_FILE" <<EOF
target "docker-metadata-action" {}

cat > "$DOCKER_BAKE_FILE" << EOF
group "default" {
targets = [$T]
targets = [$DEBIAN_TARGETS, $ALPINE_TARGETS]
}

group "debian-all" {
targets = [$DEBIAN_TARGETS]
}

group "alpine-all" {
targets = [$ALPINE_TARGETS]
}

variable "REGISTRY_PREFIX" {
Expand All @@ -32,11 +43,13 @@ variable "BUILD_REVISION" {
}

target "debian" {
inherits = ["docker-metadata-action"]
args = {"GOCRONVER" = "$GOCRONVER"}
dockerfile = "debian.Dockerfile"
}

target "alpine" {
inherits = ["docker-metadata-action"]
args = {"GOCRONVER" = "$GOCRONVER"}
dockerfile = "alpine.Dockerfile"
}
Expand Down Expand Up @@ -64,7 +77,8 @@ target "alpine-latest" {
}
EOF

for TAG in $TAGS_EXTRA; do cat >> "$DOCKER_BAKE_FILE" << EOF
for TAG in $TAGS_EXTRA; do
cat >>"$DOCKER_BAKE_FILE" <<EOF

target "debian-$TAG" {
inherits = ["debian"]
Expand Down
Loading