Skip to content

Commit ee4a106

Browse files
committed
rewrite release workflow
1 parent f32e770 commit ee4a106

File tree

1 file changed

+99
-17
lines changed

1 file changed

+99
-17
lines changed

.github/workflows/release.yaml

Lines changed: 99 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,48 @@
1-
name: Build docker Image
1+
name: Build container and chart
22

33
env:
44
IMAGE_PLATFORMS: linux/386,linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le
55

66
on:
7-
workflow_dispatch:
8-
push:
9-
branches:
10-
- main
7+
pull_request:
8+
branches-ignore:
9+
- "docu/**"
1110
paths:
1211
- "docker-image/**"
12+
- "helm/**"
13+
- ".github/workflows/**"
1314

1415
jobs:
15-
generate_tag:
16+
generate_infos:
1617
runs-on: ubuntu-latest
1718
outputs:
18-
output: ${{ steps.tag.outputs.tag }}
19+
releaseid: ${{ steps.tag.outputs.releaseid }}
20+
version: ${{ steps.tag.outputs.version }}
21+
pr: ${{ steps.tag.outputs.pr }}
1922
steps:
2023
- name: Check out the repo
2124
uses: actions/checkout@v2
22-
with:
23-
ref: main
24-
fetch-depth: 0
25-
- id: tag
25+
- name: Setup awesome-ci
26+
uses: fullstack-devops/awesome-ci-action@main
27+
28+
- name: collect infos and create release
29+
run: |
30+
awesome-ci pr info
31+
awesome-ci release create
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: collect infos
36+
id: tag
2637
shell: bash
2738
run: |
28-
echo "Tag: $(git describe --abbrev=0)"
29-
echo "::set-output name=tag::$(git describe --abbrev=0)"
30-
39+
echo "::set-output name=version::$ACI_VERSION"
40+
echo "::set-output name=pr::$ACI_PR"
41+
echo "::set-output name=releaseid::$ACI_RELEASE_ID"
42+
3143
build-image:
3244
runs-on: ubuntu-latest
33-
needs: generate_tag
45+
needs: generate_infos
3446
steps:
3547
- name: Check out the repo
3648
uses: actions/checkout@v2
@@ -56,7 +68,77 @@ jobs:
5668
builder: ${{ steps.buildx.outputs.name }}
5769
context: ./docker-image/
5870
platforms: ${{ env.IMAGE_PLATFORMS }}
59-
push: true
71+
push: false
6072
tags: |
6173
ghcr.io/${{ github.repository }}:latest
62-
ghcr.io/${{ github.repository }}:${{ needs.generate_tag.outputs.output }}
74+
ghcr.io/${{ github.repository }}:${{ needs.generate_infos.outputs.version }}
75+
76+
build-helm-chart:
77+
runs-on: ubuntu-latest
78+
needs: generate_infos
79+
steps:
80+
- name: Check out the repo
81+
uses: actions/checkout@v2
82+
83+
- name: Helm Installation
84+
uses: azure/[email protected]
85+
86+
- name: Helm Package
87+
run: helm package ./helm --version "${{ needs.generate_infos.outputs.version }}" --app-version "${{ needs.generate_infos.outputs.version }}" -d out/
88+
89+
- name: Cache build outputs
90+
uses: actions/cache@v2
91+
env:
92+
cache-name: cache-outputs-modules
93+
with:
94+
path: out/
95+
key: dns-bind-${{ github.event.pull_request.head.sha }}-${{ hashFiles('out/dns-bind*') }}
96+
restore-keys: |
97+
dns-bind-${{ github.event.pull_request.head.sha }}
98+
99+
publish_release:
100+
runs-on: ubuntu-latest
101+
needs: [generate_infos, build-image, build-helm-chart]
102+
steps:
103+
- name: Checkout code
104+
uses: actions/checkout@v2
105+
- name: Setup awesome-ci
106+
uses: fullstack-devops/awesome-ci-action@main
107+
108+
- name: get cached build outputs
109+
uses: actions/cache@v2
110+
env:
111+
cache-name: cache-outputs-modules
112+
with:
113+
path: out/
114+
key: dns-bind-${{ github.event.pull_request.head.sha }}
115+
116+
- name: Check out helm-charts
117+
uses: actions/checkout@v2
118+
with:
119+
repository: fullstack-devops/helm-charts
120+
token: ${{ secrets.HELM_REPO_TOKEN }}
121+
ref: gh-pages
122+
persist-credentials: true
123+
path: helm-charts
124+
125+
- name: Publish Release
126+
run: awesome-ci release publish -releaseid "$ACI_RELEASE_ID" -asstes "file=out/$ARTIFACT1"
127+
env:
128+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129+
ACI_RELEASE_ID: ${{ needs.generate_infos.outputs.releaseid }}
130+
ARTIFACT1: dns-bind-${{ needs.generate_infos.outputs.version }}.tgz
131+
132+
- name: Helm index
133+
env:
134+
GITHUB_TOKEN: ${{ secrets.HELM_REPO_TOKEN }}
135+
run: |
136+
git config user.name "$GITHUB_ACTOR"
137+
git config user.email "[email protected]"
138+
139+
helm repo index out/ --url "$ACI_ARTIFACT_1_URL" --merge helm-charts/index.yaml
140+
cp -f out/index.yaml helm-charts/index.yaml
141+
142+
cd helm-charts
143+
git push
144+
cat index.yaml

0 commit comments

Comments
 (0)