Skip to content

Commit

Permalink
Fix/update docker GitHub action (#5)
Browse files Browse the repository at this point in the history
* fix: trying a new gha workflow

* fix: semantic release badge fix
  • Loading branch information
nwhobart authored Mar 31, 2023
1 parent 173b240 commit d48702b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 26 deletions.
82 changes: 57 additions & 25 deletions .github/workflows/dockerbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,68 @@
name: Docker Build and Push
name: Docker Build and Publish

on:
push:
branches:
- main
- 'main'
tags:
- 'v*.*.*'

jobs:
build-and-push:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/nucleuscloud/operator
# 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=semver,pattern={{raw}}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: set up QEMU
uses: docker/setup-qemu-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
provenance: false
tags: |
ghcr.io/${{ github.repository_owner }}/pvb:latest
cache-from: type=registry,ref=${{ github.repository_owner }}/pvb:latest
cache-to: type=inline
# 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![CodeQL](https://github.com/nwhobart/pvb/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/nwhobart/pvb/actions/workflows/github-code-scanning/codeql)
[![Lint](https://github.com/nwhobart/pvb/actions/workflows/ci_workflow.yaml/badge.svg)](https://github.com/nwhobart/pvb/actions/workflows/ci_workflow.yaml)
[![Semantic Release](https://github.com/nwhobart/pvb/actions/workflows/cd.yaml/badge.svg?branch=main)](https://github.com/nwhobart/pvb/actions/workflows/cd.yaml)
[![Semantic Release](https://github.com/nwhobart/pvb/actions/workflows/release.yaml/badge.svg)](https://github.com/nwhobart/pvb/actions/workflows/release.yaml)

# pvb
Posting Terraform provider versions to a Slack channel
Expand Down

0 comments on commit d48702b

Please sign in to comment.