Skip to content

Commit 2c3f9f3

Browse files
authored
Merge pull request #7 from GitGuardian/fspiers/-/improve-ci
feat(ci): reworked all ci
2 parents 34fc5af + 9d29bbc commit 2c3f9f3

File tree

3 files changed

+26
-144
lines changed

3 files changed

+26
-144
lines changed

.github/workflows/pull-request.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ jobs:
147147
148148
publish-chart:
149149
name: Publish Helm Chart
150+
needs: [lint-test]
150151
runs-on: ubuntu-latest
151152
steps:
152153
- uses: azure/[email protected]

.github/workflows/release.yaml

Lines changed: 25 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,22 @@ on:
55
branches:
66
- main
77

8+
permissions:
9+
contents: read
10+
packages: write
11+
attestations: write
12+
id-token: write
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16+
cancel-in-progress: true
17+
818
jobs:
9-
release:
10-
permissions:
11-
contents: write
12-
packages: write
19+
publish-chart:
1320
runs-on: ubuntu-latest
1421
steps:
1522
- name: Checkout
16-
uses: actions/checkout@v5.0.0
23+
uses: actions/checkout@v5
1724
with:
1825
fetch-depth: 0
1926

@@ -22,91 +29,47 @@ jobs:
2229
git config user.name "$GITHUB_ACTOR"
2330
git config user.email "[email protected]"
2431
25-
- name: Login to Registry
26-
uses: docker/login-action@v3
27-
with:
28-
registry: ${{ vars.REGISTRY }}
29-
username: ${{ secrets.REGISTRY_USER }}
30-
password: ${{ secrets.REGISTRY_PASSWORD }}
31-
32-
- name: Login to GHCR
33-
uses: docker/login-action@v3
34-
with:
35-
registry: ghcr.io
36-
username: ${{ github.actor }}
37-
password: ${{ secrets.GITHUB_TOKEN }}
32+
- name: Login to GHCR Helm registry
33+
shell: bash
34+
run: |
35+
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login \
36+
ghcr.io \
37+
--username ${{ github.actor }} \
38+
--password-stdin
3839
3940
- name: Run chart-releaser
4041
id: chart-releaser
4142
uses: helm/[email protected]
4243
with:
4344
skip_existing: true
45+
skip_packaging: true
46+
skip_upload: true
4447
env:
4548
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
4649

47-
- name: Install cosign
48-
uses: sigstore/[email protected]
49-
if: ${{ steps.chart-releaser.outputs.changed_charts }}
50-
51-
- id: github-repo-owner-name
52-
uses: ASzc/change-string-case-action@v6
53-
with:
54-
string: ${{ github.repository_owner }}
55-
56-
- name: Upload charts to OCI registries
50+
- name: Upload charts to OCI GHCR
5751
id: upload
5852
if: ${{ steps.chart-releaser.outputs.changed_charts }}
59-
env:
60-
COSIGN_KEY: ${{ secrets.COSIGN_KEY }}
61-
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
62-
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
6353
run: |
6454
CHANGED_CHARTS="${{ steps.chart-releaser.outputs.changed_charts }}"
6555
66-
# Login to primary registry
67-
helm registry login --username $REGISTRY_USER --password ${{ secrets.REGISTRY_PASSWORD }} https://${{ vars.REGISTRY }}
68-
69-
# Login to GHCR
70-
helm registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} https://ghcr.io
71-
7256
RELEASED_CHARTS=""
7357
for chart_directory in ${CHANGED_CHARTS//,/ }; do
7458
CHART_NAME=${chart_directory#charts/}
7559
7660
cd $chart_directory
7761
78-
# Extract version and appVersion from Chart.yaml
7962
CHART_VERSION=$(yq eval '.version' "Chart.yaml")
8063
APP_VERSION=$(yq eval '.appVersion' "Chart.yaml")
8164
82-
# Push to primary registry (Docker Hub)
83-
echo "Pushing Helm chart $CHART_NAME-$CHART_VERSION.tgz to oci://${{ vars.REGISTRY }}/${{ vars.REPOSITORY }}"
84-
if helm push ${{ github.workspace }}/.cr-release-packages/${CHART_NAME}-${CHART_VERSION}.tgz oci://${{ vars.REGISTRY }}/${{ vars.REPOSITORY }} 2>&1 | tee ${CHART_NAME}-output.log; then
85-
86-
# Extract digest and sign chart
87-
DIGEST=$(cat ${CHART_NAME}-output.log | awk -F '[, ]+' '/Digest/{print $NF}')
88-
cosign sign -y --key env://COSIGN_KEY ${{ vars.REGISTRY }}/${{ vars.REPOSITORY }}/${CHART_NAME}:${CHART_VERSION}@$DIGEST
89-
90-
RELEASED_CHARTS="$RELEASED_CHARTS ${CHART_NAME}"
91-
echo "Successfully released $CHART_NAME-$CHART_VERSION to primary registry"
92-
else
93-
echo "Failed to push $CHART_NAME-$CHART_VERSION to primary registry"
94-
cat ${CHART_NAME}-output.log
95-
exit 1
96-
fi
65+
helm package . --app-version=${APP_VERSION} --version=${CHART_VERSION}
9766
9867
# Push to GHCR
99-
echo "Pushing Helm chart $CHART_NAME-$CHART_VERSION.tgz to oci://ghcr.io/${{ steps.github-repo-owner-name.outputs.lowercase }}/helm-charts"
100-
if helm push ${{ github.workspace }}/.cr-release-packages/${CHART_NAME}-${CHART_VERSION}.tgz oci://ghcr.io/${{ steps.github-repo-owner-name.outputs.lowercase }}/helm-charts 2>&1 | tee ${CHART_NAME}-ghcr-output.log; then
101-
102-
# Extract digest and sign GHCR chart
103-
GHCR_DIGEST=$(cat ${CHART_NAME}-ghcr-output.log | awk -F '[, ]+' '/Digest/{print $NF}')
104-
cosign sign -y --key env://COSIGN_KEY ghcr.io/${{ steps.github-repo-owner-name.outputs.lowercase }}/helm-charts/${CHART_NAME}:${CHART_VERSION}@$GHCR_DIGEST
105-
68+
echo "Pushing Helm chart $CHART_NAME-$CHART_VERSION.tgz to oci://ghcr.io/${{ github.event.repository.name }}"
69+
if helm push ${{ github.workspace }}/$CHART_NAME-$CHART_VERSION.tgz oci://ghcr.io/${{ github.event.repository.name }}; then
10670
echo "Successfully released $CHART_NAME-$CHART_VERSION to GHCR"
10771
else
10872
echo "Failed to push $CHART_NAME-$CHART_VERSION to GHCR"
109-
cat ${CHART_NAME}-ghcr-output.log
11073
exit 1
11174
fi
11275

.github/workflows/unstable.yaml

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)