Skip to content

Commit

Permalink
chore(github_actions): disable cache for docker build push
Browse files Browse the repository at this point in the history
Signed-off-by: Bukowa <gitbukowa@gmail.com>
  • Loading branch information
bukowa committed Jun 10, 2024
1 parent 2171653 commit 7c5d4be
Showing 1 changed file with 105 additions and 46 deletions.
151 changes: 105 additions & 46 deletions .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
@@ -1,73 +1,132 @@
name: Detect Changes
name: Build and Push Docker Images

# todo change branch main
on:
push:
branches:
- "main"
# paths:
# - "test.sh"
# - "main.go"
# - "go.mod"
# - "Dockerfile"
# - ".dockerignore"
# - ".github/**"
tags:
- "*"
workflow_dispatch:


jobs:

detect-changes:
Docker:
name: Build and Push Docker Images
runs-on: ubuntu-latest
if: github.event_name != 'workflow_dispatch'
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

steps:

-
name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
with:
fetch-depth: 0

# https://github.com/tj-actions/changed-files/blob/main/README.md#inputs
-
name: Detect Changes
uses: tj-actions/changed-files@d6babd6899969df1a11d14c368283ea4436bca78 # v44.5.2
id: changes
with:
files: |
*.go
*.mod
*Dockerfile
name: Set up Docker Build
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3

# Makefile
-
name: Generate Changelog
run: make generate-changelog-ci
if: steps.changes.outputs.any_changed == 'true'
name: Build Docker Test Image
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
id: build
with:
context: .
load: true
# cache-from: type=gha
# cache-to: type=gha,mode=max

# https://github.com/peter-evans/create-pull-request#action-inputs
-
name: Create Pull Request
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6
name: Test Docker Image
run: |
CMD="docker run --rm -i -p 9001:9001 ${{ steps.build.outputs.imageid }} --port=9001" ./test.sh
- name: Get Docker Image Metadata
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5
with:
token: "${{ secrets.GITHUB_TOKEN }}"
branch: "change/${{ github.sha }}"
commit-message: "new changes"
title: "maybe new release?"
delete-branch: true
images: |
quay.io/k8start/http-headers
ghcr.io/bukowa/http-headers
bukowa/http-headers
tags: |
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3

release-dispatched:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
- name: Login to Docker Hub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ROBOT_TOKEN }}

steps:
-
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- name: Login to GHCR.io Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3
with:
fetch-depth: 0
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate Changelog
run: make generate-changelog-ci
- name: Login to Quay.io Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6
# - name: Get Docker Expire Image Metadata
# id: meta-expire
# uses: docker/metadata-action@v4
# with:
# images: |
# quay.io/k8start/http-headers
# tags: |
# type=sha

# -
# # Push images that expire
# name: Build and Push Docker Expire Images
# uses: docker/build-push-action@v3
# with:
# context: .
# push: true
# tags: ${{ steps.meta-expire.outputs.tags }}
# labels: |
# quay.expires-after=72h
# ${{ steps.meta-expire.outputs.labels }}
# cache-from: |
# type=gha
# type=registry,ref=quay.io/k8start/http-headers
# cache-to: |
# type=gha,mode=max
# platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x

-
# Push other images
name: Build and Push Docker Images
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
id: build-all
with:
token: "${{ secrets.GITHUB_TOKEN }}"
branch: "change/${{ github.sha }}"
commit-message: "new changes"
title: "probably new release..."
delete-branch: true
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# cache-from: |
# type=gha
# type=registry,ref=quay.io/k8start/http-headers
# cache-to: |
# type=gha,mode=max
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x

0 comments on commit 7c5d4be

Please sign in to comment.