Skip to content

Commit a6e9200

Browse files
authored
Merge pull request #1 from fullstack-devops/feature/helm-and-docker-workflows
helm and docker workflows
2 parents 41e4526 + a8374d2 commit a6e9200

File tree

2 files changed

+190
-40
lines changed

2 files changed

+190
-40
lines changed

.github/workflows/pr-build.yaml

Lines changed: 92 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
name: Build helm chart
1+
name: pull-request container and chart
2+
3+
env:
4+
IMAGE_PLATFORMS: linux/386,linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le
25

36
on:
4-
workflow_dispatch:
5-
push:
6-
branches:
7-
- main
7+
pull_request:
8+
branches-ignore:
9+
- "docu/**"
810
paths:
911
- "docker-image/**"
1012
- "helm/**"
13+
- ".github/workflows/**"
1114

1215
jobs:
1316
generate_infos:
@@ -30,18 +33,84 @@ jobs:
3033
id: tag
3134
shell: bash
3235
run: |
33-
echo "Tag: $(git describe --abbrev=0)"
36+
echo "Tag: $(git describe --abbrev=0), Version: $ACI_VERSION"
3437
echo "::set-output name=tag::$(git describe --abbrev=0)"
3538
echo "::set-output name=version::$ACI_VERSION"
3639
echo "::set-output name=pr::$ACI_PR"
37-
40+
41+
build-image:
42+
runs-on: ubuntu-latest
43+
needs: generate_infos
44+
steps:
45+
- name: Check out the repo
46+
uses: actions/checkout@v2
47+
48+
- name: Login to GitHub Container Registry
49+
uses: docker/login-action@v1
50+
with:
51+
registry: ghcr.io
52+
username: ${{ github.repository_owner }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Set up QEMU
56+
uses: docker/setup-qemu-action@v1
57+
with:
58+
platforms: ${{ env.IMAGE_PLATFORMS }}
59+
- name: Set up Docker Buildx
60+
id: buildx
61+
uses: docker/setup-buildx-action@v1
62+
63+
- name: Build and push image
64+
uses: docker/build-push-action@v2
65+
with:
66+
builder: ${{ steps.buildx.outputs.name }}
67+
context: ./docker-image/
68+
platforms: ${{ env.IMAGE_PLATFORMS }}
69+
push: false
70+
tags: |
71+
ghcr.io/${{ github.repository }}:latest
72+
ghcr.io/${{ github.repository }}:${{ needs.generate_infos.outputs.version }}
73+
3874
build-helm-chart:
3975
runs-on: ubuntu-latest
40-
needs: generate_tag
76+
needs: generate_infos
4177
steps:
4278
- name: Check out the repo
4379
uses: actions/checkout@v2
4480

81+
- name: Helm Installation
82+
uses: azure/[email protected]
83+
84+
- name: Helm Package
85+
run: helm package ./helm --version "${{ needs.generate_infos.outputs.version }}" --app-version "${{ needs.generate_infos.outputs.version }}" -d out/
86+
87+
- name: Cache build outputs
88+
uses: actions/cache@v2
89+
env:
90+
cache-name: cache-outputs-modules
91+
with:
92+
path: out/
93+
key: dns-bind-${{ github.event.pull_request.head.sha }}-${{ hashFiles('out/dns-bind*') }}
94+
restore-keys: |
95+
dns-bind-${{ github.event.pull_request.head.sha }}
96+
97+
publish_release:
98+
runs-on: ubuntu-latest
99+
needs: [generate_infos, build-image, build-helm-chart]
100+
steps:
101+
- name: Checkout code
102+
uses: actions/checkout@v2
103+
- name: Setup awesome-ci
104+
uses: fullstack-devops/awesome-ci-action@main
105+
106+
- name: get cached build outputs
107+
uses: actions/cache@v2
108+
env:
109+
cache-name: cache-outputs-modules
110+
with:
111+
path: out/
112+
key: dns-bind-${{ github.event.pull_request.head.sha }}
113+
45114
- name: Check out helm-charts
46115
uses: actions/checkout@v2
47116
with:
@@ -50,26 +119,24 @@ jobs:
50119
ref: gh-pages
51120
persist-credentials: true
52121
path: helm-charts
53-
54-
- name: Helm Installation
55-
uses: azure/[email protected]
56-
with:
57-
version: v3.7.2
58122

59-
- name: Helm Package
60-
run: helm package ./helm --version "${{ needs.generate_tag.outputs.release_version }}" --app-version "${{ needs.generate_tag.outputs.release_version }}" -d out/
61-
62-
- name: Helm
63-
env:
123+
#- name: Publish Release
124+
# run: awesome-ci release publish -releaseid "$ACI_RELEASE_ID" -asstes "file=out/$ARTIFACT1"
125+
# env:
126+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127+
# ACI_RELEASE_ID: ${{ needs.generate_infos.outputs.releaseid }}
128+
# ARTIFACT1: dns-bind-${{ needs.generate_infos.outputs.version }}.tgz
129+
130+
- name: Helm index
131+
env: #ACI_ARTIFACT_1_URL
64132
GITHUB_TOKEN: ${{ secrets.HELM_REPO_TOKEN }}
65133
run: |
66134
git config user.name "$GITHUB_ACTOR"
67135
git config user.email "[email protected]"
68136
69-
helm repo index out/ --url https://github.com/fullstack-devops/helm-charts/releases/download/excalidraw-1.0.1/excalidraw-1.0.1.tgz --merge helm-charts/index.yaml
70-
71-
CHART_PACKAGE_NAME="my-chart-0.1.0+$(git rev-parse --short "$GITHUB_SHA").tgz"
72-
cd helm-chart-repository
73-
git add "$CHART_PACKAGE_NAME"
74-
git commit -m "$CHART_PACKAGE_NAME"
75-
git push origin main
137+
helm repo index out/ --url "$ACI_ARTIFACT_1_URL" --merge helm-charts/index.yaml
138+
cp -f out/index.yaml helm-charts/index.yaml
139+
140+
cd helm-charts
141+
git status
142+
cat index.yaml

.github/workflows/release.yaml

Lines changed: 98 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,48 @@
1-
name: Build docker Image
1+
name: Release 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:
87
push:
98
branches:
10-
- main
9+
- "maim"
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,78 @@ 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 status
144+
git push
145+
cat index.yaml

0 commit comments

Comments
 (0)