Skip to content

Commit 7523e4f

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

File tree

1 file changed

+55
-32
lines changed

1 file changed

+55
-32
lines changed

.github/workflows/deno-ci.yaml

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

99+
outputs:
100+
new-tag: chart-v${{ steps.chart.outputs.version }}
101+
needs-release: ${{ steps.check-tag.outputs.exists == 'false' }}
99102
steps:
100103
- name: Checkout source
101104
uses: actions/checkout@v5
102105

103106
- name: Install Helm
104107
uses: azure/setup-helm@v4
105-
with:
106-
token: ${{ secrets.GITHUB_TOKEN }}
107108

108109
- name: Evaluate Chart
109110
run: time helm template helm-chart
110111

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

119133
permissions:
120-
contents: read
134+
contents: write
121135
packages: write
122136

123137
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 }}
138+
- name: Checkout
139+
uses: actions/checkout@v5
146140

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

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

0 commit comments

Comments
 (0)