-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (121 loc) · 4.25 KB
/
pr-build.yaml
File metadata and controls
139 lines (121 loc) · 4.25 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
name: pull-request container and chart
env:
IMAGE_PLATFORMS: linux/386,linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le
on:
pull_request:
branches-ignore:
- "docu/**"
paths:
- "docker-image/**"
- "helm/**"
- ".github/workflows/**"
jobs:
generate_infos:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.tag.outputs.version }}
tag: ${{ steps.tag.outputs.tag }}
pr: ${{ steps.tag.outputs.pr }}
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Setup awesome-ci
uses: fullstack-devops/awesome-ci-action@main
- name: set build Infos
run: awesome-ci pr info -number ${{ github.event.pull_request.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: export Infos
id: tag
shell: bash
run: |
echo "Tag: $(git describe --abbrev=0), Version: $ACI_VERSION"
echo "::set-output name=tag::$(git describe --abbrev=0)"
echo "::set-output name=version::$ACI_VERSION"
echo "::set-output name=pr::$ACI_PR"
build-image:
runs-on: ubuntu-latest
needs: generate_infos
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: ${{ env.IMAGE_PLATFORMS }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Build and push image
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./docker-image/
platforms: ${{ env.IMAGE_PLATFORMS }}
push: false
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ needs.generate_infos.outputs.version }}
build-helm-chart:
runs-on: ubuntu-latest
needs: generate_infos
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Helm Installation
uses: azure/setup-helm@v1.1
- name: Helm Package
run: helm package ./helm --version "${{ needs.generate_infos.outputs.version }}" --app-version "${{ needs.generate_infos.outputs.version }}" -d out/
- name: Cache build outputs
uses: actions/cache@v2
env:
cache-name: cache-outputs-modules
with:
path: out/
key: dns-bind-${{ github.event.pull_request.head.sha }}-${{ hashFiles('out/dns-bind*') }}
restore-keys: |
dns-bind-${{ github.event.pull_request.head.sha }}
publish_release:
runs-on: ubuntu-latest
needs: [generate_infos, build-image, build-helm-chart]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup awesome-ci
uses: fullstack-devops/awesome-ci-action@main
- name: get cached build outputs
uses: actions/cache@v2
env:
cache-name: cache-outputs-modules
with:
path: out/
key: dns-bind-${{ github.event.pull_request.head.sha }}
- name: Check out helm-charts
uses: actions/checkout@v2
with:
repository: fullstack-devops/helm-charts
token: ${{ secrets.HELM_REPO_TOKEN }}
ref: gh-pages
persist-credentials: true
path: helm-charts
#- name: Publish Release
# run: awesome-ci release publish -releaseid "$ACI_RELEASE_ID" -asstes "file=out/$ARTIFACT1"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ACI_RELEASE_ID: ${{ needs.generate_infos.outputs.releaseid }}
# ARTIFACT1: dns-bind-${{ needs.generate_infos.outputs.version }}.tgz
- name: Helm index
env: #ACI_ARTIFACT_1_URL
GITHUB_TOKEN: ${{ secrets.HELM_REPO_TOKEN }}
run: |
helm repo index out/ --url "$ACI_ARTIFACT_1_URL" --merge helm-charts/index.yaml
cp -f out/index.yaml helm-charts/index.yaml
cd helm-charts
git status
cat index.yaml