diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 744b646..f29a608 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -39,8 +39,14 @@ jobs: COMMIT_TAG=$(jq -r .version package.json)-$GITHUB_SHA echo "COMMIT_TAG=$COMMIT_TAG" >> "$GITHUB_ENV" docker tag registry.christianbingman.com/personal-site:latest registry.christianbingman.com/personal-site:$COMMIT_TAG + if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then + docker tag registry.christianbingman.com/personal-site:latest registry.christianbingman.com/personal-site:$COMMIT_TAG + fi - name: Push image to repo run: "docker push registry.christianbingman.com/personal-site:$COMMIT_TAG" + - name: Push production image + if: github.ref_type == 'tag' + run: "docker push registry.christianbingman.com/personal-site:$(jq -r .version package.json)" update-chart: runs-on: christianbingman-com-runners needs: container-build diff --git a/.github/workflows/tag-and-deploy.yaml b/.github/workflows/tag-and-deploy.yaml index f2064c6..ec367dd 100644 --- a/.github/workflows/tag-and-deploy.yaml +++ b/.github/workflows/tag-and-deploy.yaml @@ -7,5 +7,28 @@ jobs: check-tag: runs-on: christianbingman-com-runners steps: - - run: env - + - name: Checkout + uses: actions/checkout@v4 + with: + sparse-checkout: | + package.json + - name: Check version matches tag + run: | + [[ "$GITHUB_REF_NAME" == "$(jq -r .version package.json)" ]] + - name: Checkout helm repo + uses: actions/checkout@v4 + with: + repository: ChristianBingman/christianbingman-com-helm + token: ${{ secrets.HELM_PAT }} + ref: main + path: chart + - name: Update app version + run: | + RELEASE_VERSION=$(jq -r .version package.json) + cd chart + sed -i -e "s/appVersion: \".\"*$/appVersion: \"$RELEASE_VERSION\"/g" Chart.yaml + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR_ID+$GITHUB_ACTOR@users.noreply.github.com" + git add Chart.yaml + git commit -m "Deploy [prod]" + git push