mirror of
https://github.com/3cky/mbusd.git
synced 2024-09-27 03:53:02 +02:00
Add docker image publish github workflow
This commit is contained in:
parent
a5239439e3
commit
9cee2351f4
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: mbusd
|
name: build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
62
.github/workflows/docker-publish.yml
vendored
Normal file
62
.github/workflows/docker-publish.yml
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
name: docker publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: [ 'build' ]
|
||||||
|
types: [ completed ]
|
||||||
|
branches: [ 'master' ]
|
||||||
|
tags: [ 'v*' ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
|
# github.repository as <account>/<repo>
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
# Extract metadata (tags, labels) for Docker
|
||||||
|
# https://github.com/docker/metadata-action
|
||||||
|
- name: Extract Docker metadata
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=sha
|
||||||
|
|
||||||
|
# Build and push Docker image with Buildx (don't push on PR)
|
||||||
|
# https://github.com/docker/build-push-action
|
||||||
|
- name: Build and push Docker image
|
||||||
|
id: build-and-push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: ${{ env.PLATFORMS }}
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha,scope=${{ env.IMAGE_NAME }}
|
||||||
|
cache-to: type=gha,mode=max,scope=${{ env.IMAGE_NAME }}
|
@ -1,4 +1,4 @@
|
|||||||
FROM alpine:latest AS build
|
FROM --platform=$BUILDPLATFORM alpine:latest AS build
|
||||||
RUN apk add --no-cache alpine-sdk cmake linux-headers
|
RUN apk add --no-cache alpine-sdk cmake linux-headers
|
||||||
COPY . /mbusd
|
COPY . /mbusd
|
||||||
WORKDIR /mbusd/build
|
WORKDIR /mbusd/build
|
||||||
|
Loading…
Reference in New Issue
Block a user