forked from juice-shop/multi-juicer
-
-
Notifications
You must be signed in to change notification settings - Fork 13
105 lines (100 loc) · 3.45 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
on:
workflow_dispatch:
release:
types: [published]
name: "Publish Docker Images"
jobs:
helmRelease:
name: "Package Helm Chart"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: "Install yq"
run: |
sudo snap install yq
- name: "Patch Chart.yaml to the current released version"
working-directory: helm/wrongsecrets-ctf-party/
run: |
RELEASE_VERSION="${GITHUB_REF#refs/*/}"
# Remove leading 'v' from git tag to create valid semver
RELEASE_VERSION="${RELEASE_VERSION//v}"
# patch the version & appVersion in the Chart.yaml to the release version
yq eval -i ".version = \"$RELEASE_VERSION\", .appVersion = \"$RELEASE_VERSION\"" Chart.yaml
- name: install helm-docs
env:
HELM_DOCS_VERSION: "1.11.0"
run: |
cd /tmp
wget https://github.com/norwoodj/helm-docs/releases/download/v${{env.HELM_DOCS_VERSION}}/helm-docs_${{env.HELM_DOCS_VERSION}}_Linux_x86_64.tar.gz
tar -xvf helm-docs_${{env.HELM_DOCS_VERSION}}_Linux_x86_64.tar.gz
sudo mv helm-docs /usr/local/sbin
- name: Generate and Release Helm Docs
run: |
helm-docs -t helm/wrongsecrets-ctf-party/README.md.gotmpl -t helm/wrongsecrets-ctf-party/_template.gotmpl -o README.md
cp helm/wrongsecrets-ctf-party/README.md /tmp/README.md
- name: Update gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
fetch-depth: 0
- name: Copy README.md to gh-pages
run: |
cp /tmp/README.md README.md
- name: Commit and push changes (if any)
run: |
if git diff --exit-code; then
echo "No changes detected."
else
echo "Changes detected."
git add README.md
git commit -m "Update README.md"
git push
fi
- name: Get back to original branch
uses: actions/checkout@v4
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
with:
charts_dir: helm
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
dockerBuilds:
name: "Build"
runs-on: ubuntu-latest
strategy:
matrix:
component:
- cleaner
- wrongsecrets-balancer
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker Meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: iteratec/${{ matrix.component }}
tags: |
type=semver,pattern={{raw}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push
uses: docker/build-push-action@v6
with:
context: ./${{ matrix.component }}
file: ./${{ matrix.component }}/Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}