Skip to content

Commit 4ebba01

Browse files
Copilotcrenshaw-dev
andcommitted
Fix workflow paths and add authentication to GitHub API
Co-authored-by: crenshaw-dev <350466+crenshaw-dev@users.noreply.github.com>
1 parent 943adc2 commit 4ebba01

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

.github/workflows/update-gitops-promoter-version.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,25 @@ jobs:
1818
steps:
1919
- name: Checkout Repository
2020
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v6.0.1
21+
with:
22+
path: current-repo
2123

2224
- name: Get latest GitOps Promoter release
2325
id: get-latest-release
2426
run: |
25-
LATEST_VERSION=$(curl -s https://api.github.com/repos/argoproj-labs/gitops-promoter/releases/latest | jq -r .tag_name)
27+
LATEST_VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
28+
https://api.github.com/repos/argoproj-labs/gitops-promoter/releases/latest | jq -r .tag_name)
29+
if [ -z "$LATEST_VERSION" ] || [ "$LATEST_VERSION" = "null" ]; then
30+
echo "Failed to fetch latest release"
31+
exit 1
32+
fi
2633
echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
2734
echo "Latest GitOps Promoter version: $LATEST_VERSION"
2835
2936
- name: Get current GitOps Promoter version
3037
id: get-current-version
3138
run: |
32-
CURRENT_VERSION=$(grep 'GITOPS_PROMOTER_VERSION:' .github/workflows/chart-diff.yaml | awk '{print $2}')
39+
CURRENT_VERSION=$(grep 'GITOPS_PROMOTER_VERSION:' current-repo/.github/workflows/chart-diff.yaml | awk '{print $2}')
3340
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
3441
echo "Current GitOps Promoter version: $CURRENT_VERSION"
3542
@@ -63,30 +70,31 @@ jobs:
6370
if: steps.check-update.outputs.update_needed == 'true'
6471
working-directory: gitops-promoter
6572
run: |
66-
kubebuilder edit --plugins=helm/v2-alpha --output-dir=.. --manifests=./dist/install.yaml
73+
kubebuilder edit --plugins=helm/v2-alpha --output-dir=../current-repo --manifests=./dist/install.yaml
6774
6875
- name: Remove example blocks from generated CRDs
6976
if: steps.check-update.outputs.update_needed == 'true'
7077
run: |
71-
sed -i 's/{{- if eq \(.Environment\)/{{ `{{- if eq .Environment` }}/g; s/{{- else if eq \(.Environment\)/{{ `{{- else if eq .Environment` }}/g; s/{{- end -}}/{{ `{{- end -}}` }}/g; s/{{- range \$key, \$value := \.ArgoCDCommitStatus/{{ `{{- range $key, $value := .ArgoCDCommitStatus` }}/g' chart/templates/crd/argocdcommitstatuses.promoter.argoproj.io.yaml
78+
sed -i 's/{{- if eq \(.Environment\)/{{ `{{- if eq .Environment` }}/g; s/{{- else if eq \(.Environment\)/{{ `{{- else if eq .Environment` }}/g; s/{{- end -}}/{{ `{{- end -}}` }}/g; s/{{- range \$key, \$value := \.ArgoCDCommitStatus/{{ `{{- range $key, $value := .ArgoCDCommitStatus` }}/g' current-repo/chart/templates/crd/argocdcommitstatuses.promoter.argoproj.io.yaml
7279
7380
- name: Update appVersion in Chart.yaml
7481
if: steps.check-update.outputs.update_needed == 'true'
7582
run: |
7683
# Remove the 'v' prefix from version for appVersion
7784
VERSION_WITHOUT_V="${{ steps.get-latest-release.outputs.latest_version }}"
7885
VERSION_WITHOUT_V="${VERSION_WITHOUT_V#v}"
79-
sed -i "s/^appVersion: .*/appVersion: \"$VERSION_WITHOUT_V\"/" chart/Chart.yaml
86+
sed -i "s/^appVersion: .*/appVersion: \"$VERSION_WITHOUT_V\"/" current-repo/chart/Chart.yaml
8087
8188
- name: Update GITOPS_PROMOTER_VERSION in chart-diff.yaml
8289
if: steps.check-update.outputs.update_needed == 'true'
8390
run: |
84-
sed -i "s/GITOPS_PROMOTER_VERSION: .*/GITOPS_PROMOTER_VERSION: ${{ steps.get-latest-release.outputs.latest_version }}/" .github/workflows/chart-diff.yaml
91+
sed -i "s/GITOPS_PROMOTER_VERSION: .*/GITOPS_PROMOTER_VERSION: ${{ steps.get-latest-release.outputs.latest_version }}/" current-repo/.github/workflows/chart-diff.yaml
8592
8693
- name: Create Pull Request
8794
if: steps.check-update.outputs.update_needed == 'true'
8895
uses: peter-evans/create-pull-request@c7fcb2c1d4c851a1d8d82dd61df0e0f8ef373e6f # v7.0.6
8996
with:
97+
path: current-repo
9098
commit-message: "chore: update GitOps Promoter to ${{ steps.get-latest-release.outputs.latest_version }}"
9199
title: "chore: update GitOps Promoter to ${{ steps.get-latest-release.outputs.latest_version }}"
92100
body: |

0 commit comments

Comments
 (0)