This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
105 lines (90 loc) · 3.32 KB
/
publish.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
name: publish
on:
push:
# don't run if pushing tags
branches-ignore:
- refs/tags/*
env:
PROJECT: quarks-secret
DOCKER_IMAGE_ORG: ghcr.io/cloudfoundry-incubator
DOCKER_IMAGE_REPOSITORY: quarks-secret
jobs:
publish:
runs-on: ubuntu-latest
# don't run 'publish' on forks
if: github.repository == 'cloudfoundry-incubator/quarks-secret'
steps:
- uses: azure/setup-helm@v1
with:
version: v3.3.4
- uses: actions/checkout@master
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install shared tools
run: bin/tools
- name: Setup git
run: |
git config --global user.name "CFContainerizationBot"
git config --global user.email "cf-containerization@cloudfoundry.org"
- name: Prepare ARTIFACT_VERSION env
shell: bash
run: |
git fetch --unshallow
GITHUB_ACTION_BRANCH=${GITHUB_REF#refs/heads/}
. bin/include/versioning
echo "##[set-output name=version;]$(echo $ARTIFACT_VERSION)"
id: prepare_version_env
- name: Vendor go mod dependencies
run: go mod vendor
- name: Publish Docker Image
uses: whoan/docker-build-with-cache-action@v5
with:
username: cfcontainerizationbot
password: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
registry: "${{ env.DOCKER_IMAGE_ORG }}"
image_name: "${{ env.DOCKER_IMAGE_REPOSITORY }}"
image_tag: "${{ steps.prepare_version_env.outputs.version }}"
- name: Publish Lite Image
uses: whoan/docker-build-with-cache-action@v5
with:
username: cfcontainerizationbot
password: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
registry: "${{ env.DOCKER_IMAGE_ORG }}"
image_name: "${{ env.DOCKER_IMAGE_REPOSITORY }}"
image_tag: "${{ steps.prepare_version_env.outputs.version }}-lite"
dockerfile: Dockerfile-lite
- name: Build Helm Chart
run: |
echo "Publish Helm Chart for $ARTIFACT_VERSION"
cp -r "deploy/helm" "helm"
perl -pi -e "s|repository: .*|repository: $DOCKER_IMAGE_REPOSITORY|g" "helm/$PROJECT/values.yaml"
perl -pi -e "s|org: .*|org: $DOCKER_IMAGE_ORG|g" "helm/$PROJECT/values.yaml"
perl -pi -e "s|tag: .*|tag: $ARTIFACT_VERSION|g" "helm/$PROJECT/values.yaml"
# helm compatible version string
version=$(echo "$ARTIFACT_VERSION" | sed 's/^v//')
helm package "helm/$PROJECT" \
--app-version "$version" \
--version "$version" \
--destination "helm"
env:
ARTIFACT_VERSION: "${{ steps.prepare_version_env.outputs.version }}"
- name: Checkout helm chart repo
uses: actions/checkout@master
with:
repository: cloudfoundry-incubator/quarks-helm
ref: refs/heads/master
path: updated
# github personal access token, for pushing commits
token: ${{ secrets.GH_PASSWORD }}
- name: Publish Helm Chart
run: |
bin/publish-helm-repo
echo "Tag Github Commit with $ARTIFACT_VERSION"
git tag -a "$ARTIFACT_VERSION" -m "tag $ARTIFACT_VERSION"
git push origin "$ARTIFACT_VERSION"
env:
ARTIFACT_VERSION: "${{ steps.prepare_version_env.outputs.version }}"