Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/update docker GitHub action #5

Merged
merged 2 commits into from
Mar 31, 2023
Merged
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
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