-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (82 loc) · 2.55 KB
/
build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Build and Push
on:
push:
tags:
- '*.*.*'
env:
GO_VERSION: 1.21
permissions:
contents: write
packages: write
jobs:
Deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure git to trust the workspace despite the different owner
run: git config --global --add safe.directory $(realpath .)
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/randsw/kubeinfo
flavor: latest=true
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to Github Packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image and push to GitHub Container Registry
uses: docker/build-push-action@v5
with:
# relative path to the place where source code with Dockerfile is located
context: .
# Note: tags has to be all lower-case
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
Release:
needs: Deploy
name: "Release"
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if tag belong to commit in main branch
uses: rickstaa/action-contains-tag@v1
id: contains_tag_main
with:
reference: "main"
tag: "${{ github.ref }}"
- name: Check if tag belong to commit in develop branch
uses: rickstaa/action-contains-tag@v1
id: contains_tag_develop
with:
reference: "develop"
tag: "${{ github.ref }}"
- name: Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
if: ${{ steps.contains_tag_main.outputs.retval == 'true'}}
- name: Pre-Release
uses: softprops/action-gh-release@v1
with:
prerelease: true
generate_release_notes: true
if: ${{ steps.contains_tag_develop.outputs.retval == 'true'}}