8000 ci: new image build workflow by emerconn · Pull Request #188 · akpw/mktxp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ci: new image build workflow #188

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

Merged
merged 3 commits into from
Sep 12, 2024
Merged
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
111 changes: 48 additions & 63 deletions .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
@@ -1,85 +1,70 @@
---
# template source: https://github.com/bretfisher/docker-build-workflow/blob/main/templates/call-docker-build.yaml
name: Docker Build

on:
push:
branches:
- main
# don't rebuild image if someone only edited unrelated files
branches: ['**']
tags: ['**']
paths-ignore:
- 'README.md'
- 'LICENSE'
pull_request:
10000 # don't rebuild image if someone only edited unrelated files
types: [opened, reopened]
branches: [main]
paths-ignore:
- 'README.md'
- 'LICENSE'
release:
types: [published]

jobs:
call-docker-build:

name: Call Docker Build

uses: bretfisher/docker-build-workflow/.github/workflows/reusable-docker-build.yaml@2f9fdc0325196df9f11bfe4263e277793e648922

runs-on: ubuntu-latest
permissions:
contents: read
packages: write # needed to push docker image to ghcr.io
pull-requests: write # needed to create and update comments in PRs

secrets:

# Only needed if with:dockerhub-enable is true below
# https://hub.docker.com/settings/security
dockerhub-username: ""
dockerhub-token: ""
packages: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4

with:

### REQUIRED
### ENABLE ONE OR BOTH REGISTRIES
### tell docker where to push.
### NOTE if Docker Hub is set to true, you must set secrets above and also add account/repo/tags below
dockerhub-enable: false
ghcr-enable: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

### A list of the account/repo names for docker build. List should match what's enabled above
### defaults to:
image-names: |
name=ghcr.io/${{ github.repository }}
# name=${{ github.repository }},enable=false
- name: Collect Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
flavor: latest=false
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch

### set rules for tagging images, based on special action syntax:
### https://github.com/docker/metadata-action#tags-input
### defaults to:
#tag-rules: |
# type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
# type=raw,value=stable-{{date 'YYYYMMDDHHmmss'}},enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
# type=ref,event=pr
# type=ref,event=branch
# type=raw,value=gha-${{ github.run_id }}

### path to where docker should copy files into image
### defaults to root of repository (.)
# context: .

### Dockerfile alternate name. Default is Dockerfile (relative to context path)
# file: Containerfile
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: amd64,arm64

### build stage to target, defaults to empty, which builds to last stage in Dockerfile
# target:

### platforms to build for
### defaults to linux/amd64
### other options: linux/amd64,linux/arm64,linux/arm/v7
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/386

### Create a PR comment with image tags and labels
### defaults to true
# comment-enable: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Additionals parameters
# (cf https://github.com/marketplace/actions/docker-metadata-action#flavor-input)
flavor-rules: |
latest=auto
- name: Build and publish Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: |
linux/amd64
linux/arm64/v8
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-to: type=gha,mode=min
cache-from: type=gha
0