ci: don't fail the workflow if it already exists #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Chart | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
release: | |
permissions: | |
packages: write | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Get chart version | |
run: | | |
CHART_VERSION=$(echo ${{ github.ref_name }} | grep -Eo "v.*") | |
echo "CHART_VERSION=${CHART_VERSION}" >> $GITHUB_ENV | |
- name: Login to ghcr.io | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check if chart exists | |
id: chartExists | |
run: | | |
set +e | |
docker manifest inspect ghcr.io/henrywhitaker3/prompage-helm:${{ env.CHART_VERSION }} | |
rc=$? | |
set -e | |
if [ $rc -eq 0 ]; then | |
echo "::set-output name=CHART_EXISTS::'yes'" | |
else | |
echo "::set-output name=CHART_EXISTS::'no'" | |
fi | |
- name: Push chart | |
if: steps.chartExists.outputs.CHART_EXISTS == 'no' | |
uses: appany/[email protected] | |
with: | |
name: prompage-helm | |
repository: henrywhitaker3 | |
tag: ${{ env.CHART_VERSION }} | |
path: chart | |
registry: ghcr.io | |
registry_username: ${{ github.actor }} | |
registry_password: ${{ secrets.GITHUB_TOKEN }} | |
update_dependencies: 'true' |