diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index ee51cfe..6cab931 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -1,4 +1,4 @@ -name: build image +name: "build image" on: push: @@ -13,11 +13,16 @@ jobs: runs-on: ubuntu-latest environment: default outputs: + VERSION_KIND: ${{ steps.config_step.outputs.VERSION_KIND }} VERSION_STR: ${{ steps.config_step.outputs.VERSION_STR }} + ALT_TAGS: ${{ steps.config_step.outputs.ALT_TAGS }} steps: - name: "Determine Version" id: config_step run: |- + #VER_KIND = 'alpha' (not deployed) | 'dev' | 'beta' | 'gold' + VER_KIND=dev + VER_BUILD=$(date +%H%M) # limit to only first 3 chars VER_BUILD=${VER_BUILD:0:3} @@ -25,10 +30,25 @@ jobs: VERSION_NUM="$(date +%y).$(date +%-m).$(date +%-d).${VER_BUILD#0}" # recreate as INT, leaving 0's in place; creates a 'reasonable' 32-bit signed int. VERSION_INT="$(date +%y)$(date +%m)$(date +%d)${VER_BUILD}" - VERSION_STR=${VERSION_NUM} + + REF_NAME="${{ github.ref_name }}" + if [[ ${REF_NAME} =~ ^(v)([[:digit:]]+\..*)$ ]]; then + VER_KIND=gold + VERSION_STR=${BASH_REMATCH[2]} + else + ALT_TAGS="" + if [[ "${REF_NAME}" == "develop" ]]; then + ALT_TAGS+=",ci-develop" + else + ALT_TAGS=",ci-dev-${REF_NAME#**/}" + fi + fi echo "VERSION_STR=${VERSION_STR}" >> $GITHUB_OUTPUT - echo "::notice::Version STR=${VERSION_STR}" + echo "ALT_TAGS=${ALT_TAGS}" >> $GITHUB_OUTPUT + echo "VERSION_KIND=${VER_KIND}" >> $GITHUB_OUTPUT + + echo "::notice::Version KIND=${VER_KIND}, STR=${VERSION_STR}${ALT_TAGS}, INT=${VERSION_INT}" #endjob build_cfg trigger-build: @@ -57,12 +77,12 @@ jobs: "dockerfile": "Dockerfile", "arch_allowed": "amd64 arm64", "name": "${{ github.repository }}", - "tag": "${{ needs.build_cfg.outputs.VERSION_STR }}", + "tag": "${{ needs.build_cfg.outputs.VERSION_STR }}${{ needs.build_cfg.outputs.ALT_TAGS }}", "build_args": [ ] }, "deployment": { - "deploy_flag": "${{ github.ref_type == 'branch' }}", + "deploy_flag": "${{ needs.build_cfg.outputs.VERSION_KIND == 'dev' }}", "k8s_project": "${{ env.K8S_PROJECT }}", "k8s_container": "${{ env.K8S_CONTAINER }}", "deploy_msg": "${{ env.SLACK_DEPLOY_MSG }}" diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index c19639d..48212ab 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -11,6 +11,8 @@ jobs: runs-on: ubuntu-latest outputs: VERSION_STR: ${{ steps.config_step.outputs.VERSION_STR }} + VERSION_INT: ${{ steps.config_step.outputs.VERSION_INT }} + ALT_TAGS: ${{ steps.config_step.outputs.ALT_TAGS }} permissions: contents: write steps: @@ -22,13 +24,15 @@ jobs: VER_BUILD=${VER_BUILD:0:3} # 'strict' semver segments cannot start with 0 VERSION_NUM="$(date +%y).$(date +%-m).$(date +%-d).${VER_BUILD#0}" - # recreate as INT, leaving 0's in place; creates a 'reasonable' 32-bit signed int. VERSION_INT="$(date +%y)$(date +%m)$(date +%d)${VER_BUILD}" + echo "VERSION_INT=${VERSION_INT}" >> $GITHUB_OUTPUT VERSION_STR=${VERSION_NUM} + ALT_TAGS=",ci-main" echo "VERSION_STR=${VERSION_STR}" >> $GITHUB_OUTPUT - echo "::notice::Version STR=${VERSION_STR}" + echo "ALT_TAGS=${ALT_TAGS}" >> $GITHUB_OUTPUT + echo "::notice::Version STR=${VERSION_STR}${ALT_TAGS}" - name: "Create Release" uses: softprops/action-gh-release@v1 @@ -67,7 +71,7 @@ jobs: "dockerfile": "Dockerfile", "arch_allowed": "amd64 arm64", "name": "${{ github.repository }}", - "tag": "${{ needs.build_cfg.outputs.VERSION_STR }}", + "tag": "${{ needs.build_cfg.outputs.VERSION_STR }}${{ needs.build_cfg.outputs.ALT_TAGS }}", "build_args": [ ] }, diff --git a/channel_log.go b/channel_log.go index 8ab137d..bdfe616 100644 --- a/channel_log.go +++ b/channel_log.go @@ -45,7 +45,7 @@ func sanitizeSecrets(body string) string { pattern, exists := os.LookupEnv("COURIER_SANITIZE_PATTERN") if !exists { - pattern = "(?:^Po-Api-Key:.+\\n|^X-Api-Key:.+\\n|^Authorization:.+\\n|^Token:.+\\n)+" + pattern = `(?m)(?:^Po-Api-Key:.+\n|^X-Api-Key:.+\n|^Authorization:.+\n|^Token:.+\n)+` } if sanitizeSecretsRegexp == nil { diff --git a/handlers/postmaster/postmaster.go b/handlers/postmaster/postmaster.go index 5a42c5c..4081d43 100644 --- a/handlers/postmaster/postmaster.go +++ b/handlers/postmaster/postmaster.go @@ -205,10 +205,7 @@ func (h *handler) SendMsg(ctx context.Context, msg courier.Msg) (courier.MsgStat return nil, fmt.Errorf("invalid chat mode") } - deviceId := msg.Channel().ConfigForKey("device_id", "").(string) - if deviceId == "" { - return nil, fmt.Errorf("invalid chat mode") - } + deviceId := msg.Channel().Address() status := h.Backend().NewMsgStatusForID(msg.Channel(), msg.ID(), courier.MsgErrored) @@ -282,10 +279,7 @@ func (h *handler) PurgeOutgoing(ctx context.Context, channel courier.Channel) er return fmt.Errorf("invalid chat mode") } - deviceID := channel.ConfigForKey("device_id", "").(string) - if deviceID == "" { - return fmt.Errorf("invalid chat mode") - } + deviceID := channel.Address() pr := purgeRequest{ DeviceID: deviceID,