Skip to content

Commit

Permalink
Cleanup container build
Browse files Browse the repository at this point in the history
  • Loading branch information
maetthu committed Jan 14, 2025
1 parent 45791f5 commit c5b3e96
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.docker
.github
.venv
test_data
50 changes: 28 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,49 @@ on:
- cron: '15 12 * * 1'

env:
QUAY_IMAGE: quay.io/zebbra/netbox-init
CONTAINER_PLATFORMS: "linux/amd64,linux/arm64"
TAG: latest
REGISTRY: quay.io
IMAGE: zebbra/netbox-init
PLATFORMS: "linux/amd64,linux/arm64"

jobs:
build:
runs-on: ubuntu-latest
runs-on: hetzner
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4

# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to quay.io Container Registry
- name: Generate image tags
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE }}
tags: |
type=raw, value=latest
type=sha
- name: Login to container registry
uses: docker/login-action@v3
with:
registry: quay.io
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4

- name: Generate image tag
id: tag
run: echo "tag=$(date +%Y%m%d%H%M)-${{ env.GITHUB_SHA_SHORT }}" >> "$GITHUB_OUTPUT"

- name: Build
run: >
docker buildx build --pull --push
-t ${{ env.QUAY_IMAGE }}:${{ env.TAG }}
-t ${{ env.QUAY_IMAGE }}:${{ steps.tag.outputs.tag }}
--platform ${{ env.CONTAINER_PLATFORMS }}
.
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: ${{ env.PLATFORMS }}
tags: ${{ steps.meta.outputs.tags }}

0 comments on commit c5b3e96

Please sign in to comment.