From 40bb9c9373319f46a32cafdc2385a86d6b01c7ed Mon Sep 17 00:00:00 2001 From: Ryan Fischbach Date: Mon, 12 Feb 2024 08:30:47 -0800 Subject: [PATCH] gha: auto-tag-release. [skip ci] --- .github/workflows/build-image.yml | 4 +- .github/workflows/tag-release.yml | 80 +++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/tag-release.yml diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 0cf2ba8..2f44be4 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -15,7 +15,7 @@ jobs: outputs: VERSION_STR: ${{ steps.config_step.outputs.VERSION_STR }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Determine Version" id: config_step @@ -35,7 +35,7 @@ jobs: SLACK_DEPLOY_MSG: steps: - name: "Trigger Container Build" - uses: peter-evans/repository-dispatch@v2 + uses: peter-evans/repository-dispatch@v3 with: token: ${{ secrets.CI_WEBHOOK_TOKEN }} repository: istresearch/ci-docker diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml new file mode 100644 index 0000000..6cfb155 --- /dev/null +++ b/.github/workflows/tag-release.yml @@ -0,0 +1,80 @@ +name: "Tag Release" + +on: + push: + branches: + - main + - master + +jobs: + build_cfg: + runs-on: ubuntu-latest + outputs: + VERSION_STR: ${{ steps.config_step.outputs.VERSION_STR }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - name: "Create Version STR" + id: config_step + run: |- + VER_BUILD=$(date +%-H%M) + VERSION_STR="v$(date +%y).$(date +%-m).$(date +%-d)-${VER_BUILD:0:3}" + echo "VERSION_STR=${VERSION_STR}" >> $GITHUB_OUTPUT + echo "::notice::Version STR=${VERSION_STR}" + + - name: "Create Release" + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.config_step.outputs.VERSION_STR }} + release_name: ${{ steps.config_step.outputs.VERSION_STR }} + generate_release_notes: true + target_commitish: ${{ github.ref_name }} + #endjob build_cfg + + trigger-build: + runs-on: ubuntu-latest + needs: [build_cfg] + environment: default + env: + K8S_PROJECT: pulse-engage-courier + K8S_CONTAINER: courier + SLACK_DEPLOY_MSG: + steps: + - name: "Trigger Container Build" + uses: peter-evans/repository-dispatch@v3 + with: + token: ${{ secrets.CI_WEBHOOK_TOKEN }} + repository: istresearch/ci-docker + event-type: build-repo + client-payload: |- + { + "repo": { + "name": "${{ github.repository }}", + "ref_type": "${{ github.ref_type }}", + "ref_name": "${{ github.ref_name }}" + }, + "image": { + "dockerfile": "Dockerfile", + "arch_allowed": "amd64 arm64", + "name": "${{ github.repository }}", + "version": "${{ needs.build_cfg.outputs.VERSION_STR }}", + "build_args": [ + ] + }, + "deployment": { + "deploy_flag": "${{ github.ref_type == 'branch' }}", + "k8s_project": "${{ env.K8S_PROJECT }}", + "k8s_container": "${{ env.K8S_CONTAINER }}", + "deploy_msg": "${{ env.SLACK_DEPLOY_MSG }}" + }, + "callback": { + "repository": "${{ github.repository }}", + "event_type": "build_image_result", + "error_type": "build_image_error" + } + } + #endjob trigger-build