-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (108 loc) · 3.37 KB
/
release.yml
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Release
on:
workflow_dispatch:
push:
tags:
- "**"
env:
REPO_NAME: be-friends-api
PAGES_BRANCH: gh-pages
permissions:
contents: write
packages: write
repository-projects: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
config-inline: |
[worker.oci]
max-parallelism = 2
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build container image
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile
build-args: |
TAG=${{ github.ref_name }}
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ github.sha }}
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
ghcr.io/${{ github.repository }}:latest
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
helm-chart:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.8.1
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
path: ${{ env.REPO_NAME }}
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
ref: ${{ env.PAGES_BRANCH }}
path: ${{ env.PAGES_BRANCH }}
- run: tree .
- name: package charts
run: |
echo ${PWD}
cd ${{ env.REPO_NAME }}
echo "TAG: ${GITHUB_REF_NAME}"
sed -i "s/version:.*/version: ${GITHUB_REF_NAME}/" helm/Chart.yaml
sed -i "s/appVersion:.*/appVersion: \"${GITHUB_REF_NAME}\"/" helm/Chart.yaml
helm package helm --destination ../${{ env.PAGES_BRANCH }}
helm repo index ../${{ env.PAGES_BRANCH }} --url https://${{ github.repository_owner }}.github.io/${{ env.REPO_NAME }}
- name: push chart to ${{ env.PAGES_BRANCH }}
run: |
echo ${PWD}
cd ${{ env.PAGES_BRANCH }}
git config --local user.name "${{ github.repository_owner }}"
git config --local user.email "47479090+cjtim@users.noreply.github.com"
git remote set-url origin https://${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git add -A
git commit -m "Update helm chart ${GITHUB_REF_NAME}"
git push -u origin ${{ env.PAGES_BRANCH }}