Skip to content

Commit

Permalink
Restore mattermost task in create_variants workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandroboron committed Mar 26, 2024
1 parent 7a77cb6 commit ca54821
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 38 deletions.
38 changes: 0 additions & 38 deletions .github/workflows/create_dmg_variant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,41 +238,3 @@ jobs:
aws s3 cp duckduckgo.dmg \
s3://${{ vars.RELEASE_BUCKET_NAME }}/${{ vars.RELEASE_BUCKET_PREFIX }}/${{ steps.set-variant-name.outputs.variant-name }}/duckduckgo.dmg \
--acl public-read
mattermost:

name: Send Mattermost message

needs: create-dmg-variant

runs-on: ubuntu-latest

env:
success: ${{ needs.create-dmg-variant.result == 'success' }}
failure: ${{ needs.create-dmg-variant.result == 'failure' }}

steps:
- name: Send Mattermost message
if: ${{ env.success || env.failure }} # Don't execute when cancelled
env:
GH_TOKEN: ${{ github.token }}
WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
curl -fLSs $(gh api https://api.github.com/repos/${{ github.repository }}/contents/scripts/assets/variants-release-mm-template.json?ref=${{ github.ref }} --jq .download_url) \
--output message-template.json
export MM_USER_HANDLE=$(base64 -d <<< ${{ secrets.MM_HANDLES_BASE64 }} | jq ".${{ github.actor }}" | tr -d '"')

if [[ -z "${MM_USER_HANDLE}" ]]; then
echo "Mattermost user handle not known for ${{ github.actor }}, skipping sending message"
else

if [[ "${{ env.success }}" == "true" ]]; then
status="success"
else
status="failure"
fi
curl -s -H 'Content-type: application/json' \
-d "$(envsubst < message-template.json | jq ".${status}")" \
${{ secrets.MM_WEBHOOK_URL }}
fi
37 changes: 37 additions & 0 deletions .github/workflows/create_variants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,40 @@ jobs:
MM_WEBHOOK_URL: ${{ secrets.MM_WEBHOOK_URL }}
AWS_ACCESS_KEY_ID_RELEASE_S3: ${{ secrets.AWS_ACCESS_KEY_ID_RELEASE_S3 }}
AWS_SECRET_ACCESS_KEY_RELEASE_S3: ${{ secrets.AWS_SECRET_ACCESS_KEY_RELEASE_S3 }}

mattermost:
if: false

name: Send Mattermost message
needs: create-variants
runs-on: ubuntu-latest

env:
success: ${{ needs.create-variants.result == 'success' }}
failure: ${{ needs.create-variants.result == 'failure' }}

steps:
- name: Send Mattermost message
if: ${{ env.success || env.failure }} # Don't execute when cancelled
env:
GH_TOKEN: ${{ github.token }}
WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
curl -fLSs $(gh api https://api.github.com/repos/${{ github.repository }}/contents/scripts/assets/variants-release-mm-template.json?ref=${{ github.ref }} --jq .download_url) \
--output message-template.json
export MM_USER_HANDLE=$(base64 -d <<< ${{ secrets.MM_HANDLES_BASE64 }} | jq ".${{ github.actor }}" | tr -d '"')

if [[ -z "${MM_USER_HANDLE}" ]]; then
echo "Mattermost user handle not known for ${{ github.actor }}, skipping sending message"
else

if [[ "${{ env.success }}" == "true" ]]; then
status="success"
else
status="failure"
fi
curl -s -H 'Content-type: application/json' \
-d "$(envsubst < message-template.json | jq ".${status}")" \
${{ secrets.MM_WEBHOOK_URL }}
fi

0 comments on commit ca54821

Please sign in to comment.