Skip to content

Commit

Permalink
Added build container action
Browse files Browse the repository at this point in the history
Signed-off-by: fastlorenzo <[email protected]>
  • Loading branch information
fastlorenzo committed Nov 12, 2023
1 parent 68b1368 commit aaa30bc
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
82 changes: 82 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Build and push containers

on:
push:
# For push to main branch (PR merges)
branches:
- main
- master
# For releases
tags:
- "*"
# For pull requests
pull_request:
branches:
- "*"

permissions:
contents: read
packages: write

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository_owner }}/steve
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cache Docker layers
uses: actions/cache@v3
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-steve
restore-keys: |
${{ runner.os }}-buildx-steve
${{ runner.os }}-buildx-
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./
file: ./k8s/docker/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
build-args: |
DOCKER_METADATA_OUTPUT_JSON
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=steve container for k8s

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/target
/.idea
/.vscode
*.iml
.DS_Store
.DS_Store

0 comments on commit aaa30bc

Please sign in to comment.