Spaces:
Building
Building
Merge pull request #1 from moeflow-com/add-gh-action
Browse files
.github/workflows/build-server-image.yaml
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Build Docker image
|
2 |
+
|
3 |
+
on:
|
4 |
+
workflow_dispatch:
|
5 |
+
pull_request:
|
6 |
+
push:
|
7 |
+
tags:
|
8 |
+
- "v**"
|
9 |
+
branches:
|
10 |
+
- master
|
11 |
+
- main
|
12 |
+
|
13 |
+
env:
|
14 |
+
REGISTRY: ghcr.io
|
15 |
+
IMAGE_NAME: ${{ github.repository }}
|
16 |
+
|
17 |
+
jobs:
|
18 |
+
build-and-push-image:
|
19 |
+
runs-on: ubuntu-latest
|
20 |
+
|
21 |
+
permissions:
|
22 |
+
contents: read
|
23 |
+
packages: write
|
24 |
+
|
25 |
+
steps:
|
26 |
+
- name: Checkout repository
|
27 |
+
uses: actions/checkout@v3
|
28 |
+
|
29 |
+
- name: Log in to the Container registry
|
30 |
+
uses: docker/[email protected]
|
31 |
+
with:
|
32 |
+
registry: ${{ env.REGISTRY }}
|
33 |
+
username: ${{ github.actor }}
|
34 |
+
password: ${{ secrets.GITHUB_TOKEN }}
|
35 |
+
|
36 |
+
- name: Extract metadata (tags, labels) for Docker
|
37 |
+
id: meta
|
38 |
+
uses: docker/[email protected]
|
39 |
+
with:
|
40 |
+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
41 |
+
tags: | # almost same as action default
|
42 |
+
type=ref,event=pr
|
43 |
+
type=ref,event=tag,pattern={{raw}}
|
44 |
+
# type=ref,event=workflow_dispatch
|
45 |
+
type=sha,event=workflow_dispatch
|
46 |
+
|
47 |
+
- name: Setup docker buildx
|
48 |
+
uses: docker/setup-buildx-action@v2
|
49 |
+
|
50 |
+
- name: Build and push Docker image
|
51 |
+
uses: docker/[email protected]
|
52 |
+
with:
|
53 |
+
context: .
|
54 |
+
push: true # ${{ github.event_name != 'pull_request' }}
|
55 |
+
build-args: {}
|
56 |
+
cache-from:
|
57 |
+
type=gha
|
58 |
+
cache-to:
|
59 |
+
type=gha
|
60 |
+
# platforms: linux/arm64,linux/amd64
|
61 |
+
tags: ${{ steps.meta.outputs.tags }}
|
62 |
+
labels: ${{ steps.meta.outputs.labels }}
|