Skip to content

Commit d47ee34

Browse files
committed
ci: Don't republish chart
1 parent 98a9413 commit d47ee34

File tree

1 file changed

+54
-32
lines changed

1 file changed

+54
-32
lines changed

.github/workflows/deno-ci.yaml

Lines changed: 54 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -96,58 +96,80 @@ jobs:
9696
runs-on: ubuntu-latest
9797
name: Check Helm chart
9898

99+
outputs:
100+
needs-release: ${{ steps.check-tag.outputs.exists == 'false' }}
99101
steps:
100102
- name: Checkout source
101103
uses: actions/checkout@v5
102104

103105
- name: Install Helm
104106
uses: azure/setup-helm@v4
105-
with:
106-
token: ${{ secrets.GITHUB_TOKEN }}
107107

108108
- name: Evaluate Chart
109109
run: time helm template helm-chart
110110

111+
- name: Determine chart version
112+
id: chart
113+
run: |
114+
helm show chart helm-chart
115+
VERSION=$(helm show chart helm-chart|grep version|cut -d' ' -f2)
116+
echo "Helm chart version is $VERSION"
117+
echo "version=$VERSION" >> $GITHUB_OUTPUT
118+
- name: Check if chart tag exists already
119+
uses: mukunku/[email protected]
120+
id: check-tag
121+
with:
122+
tag: 'chart-v${{ steps.chart.outputs.version }}'
123+
111124
push-chart:
112125
needs:
113126
- push
114127
- check-chart
115128
runs-on: ubuntu-latest
116129
name: 'Push Helm chart'
117-
if: github.event_name == 'push'
130+
if: ${{ github.event_name == 'push' && needs.check-chart.outputs.needs-release == 'true' }}
118131

119132
permissions:
120-
contents: read
133+
contents: write
121134
packages: write
122135

123136
steps:
124-
- name: Checkout
125-
uses: actions/checkout@v5
126-
127-
- name: Determine image tag
128-
id: name
129-
run: |
130-
if [[ "${{ github.ref }}" == "refs/tags/"* ]]
131-
then VERSION=$( echo $VERSION | sed -e 's/^v//' )
132-
else VERSION=$( echo ${{ github.sha }} | cut -c1-7 )
133-
fi
134-
echo "Will push tag $VERSION"
135-
echo "tag=$VERSION" >> $GITHUB_OUTPUT
136-
137-
- name: Install Helm
138-
uses: azure/setup-helm@v4
139-
with:
140-
token: ${{ secrets.GITHUB_TOKEN }}
141-
142-
- name: Login to GitHub Container Registry
143-
run: echo "${GITHUB_TOKEN}" | helm registry login ghcr.io --username ${GITHUB_ACTOR} --password-stdin
144-
env:
145-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
137+
- name: Checkout
138+
uses: actions/checkout@v5
146139

147-
- name: Package chart
148-
working-directory: helm-chart
149-
run: helm package . -u -d dist --app-version "${{ steps.name.outputs.tag }}"
140+
- name: Install Helm
141+
uses: azure/setup-helm@v4
150142

151-
- name: Push chart
152-
working-directory: helm-chart
153-
run: helm push dist/*.tgz oci://ghcr.io/cloudydeno/charts
143+
- name: Determine image tag
144+
id: name
145+
run: |
146+
if [[ "${{ github.ref }}" == "refs/tags/"* ]]
147+
then VERSION=$( echo $VERSION | sed -e 's/^v//' )
148+
else VERSION=$( echo ${{ github.sha }} | cut -c1-7 )
149+
fi
150+
echo "Will push tag $VERSION"
151+
echo "tag=$VERSION" >> $GITHUB_OUTPUT
152+
153+
- name: Login to GitHub Container Registry
154+
run: echo "${GITHUB_TOKEN}" | helm registry login ghcr.io --username ${GITHUB_ACTOR} --password-stdin
155+
env:
156+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157+
158+
- name: Package chart
159+
working-directory: helm-chart
160+
run: helm package . -u -d dist --app-version "${{ steps.name.outputs.tag }}"
161+
162+
- name: Push chart
163+
working-directory: helm-chart
164+
run: helm push dist/*.tgz oci://ghcr.io/cloudydeno/charts
165+
166+
- name: Create chart tag
167+
uses: actions/github-script@v5
168+
with:
169+
script: |
170+
github.rest.git.createRef({
171+
owner: context.repo.owner,
172+
repo: context.repo.repo,
173+
ref: 'refs/tags/chart-v${{ steps.chart.outputs.version }}',
174+
sha: context.sha
175+
})

0 commit comments

Comments
 (0)