Skip to content

Commit

Permalink
Maybe moving slack notifications so they work again
Browse files Browse the repository at this point in the history
  • Loading branch information
sammyd committed Sep 24, 2024
1 parent 0e4152e commit 8667263
Showing 1 changed file with 47 additions and 41 deletions.
88 changes: 47 additions & 41 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,7 @@ env:
REGISTRY_IMAGE: razeware/robles

jobs:
determine_environment:
name: Determine environment
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.set_environment.outputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set environment
id: set_environment
run: |
if [[ $GITHUB_REF == 'refs/heads/development' ]]; then
echo "environment=staging" >> $GITHUB_OUTPUT
# Else if tag starts with v, then it's a release
elif [[ $GITHUB_REF == 'refs/tags/v'* ]]; then
echo "environment=production" >> $GITHUB_OUTPUT
else
echo "environment=na" >> $GITHUB_OUTPUT
fi
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
test:
runs-on: ubuntu-latest

Expand All @@ -65,12 +42,53 @@ jobs:
status: FAILED
color: danger

notify_slack:
name: Tell slack we're starting a build
runs-on: ubunut-latest
outputs:
slack_message_id: ${{ steps.slack.outputs.message_id }}
steps:
- name: Notify slack - build starting
uses: zuplo/github-action-slack-notify-build@v2
if: success()
id: slack
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel: build
status: STARTING
color: warning


determine_environment:
name: Determine environment
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.set_environment.outputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set environment
id: set_environment
run: |
if [[ $GITHUB_REF == 'refs/heads/development' ]]; then
echo "environment=staging" >> $GITHUB_OUTPUT
# Else if tag starts with v, then it's a release
elif [[ $GITHUB_REF == 'refs/tags/v'* ]]; then
echo "environment=production" >> $GITHUB_OUTPUT
else
echo "environment=na" >> $GITHUB_OUTPUT
fi
# Push image to DockerHub.
build:
# Ensure test job passes before pushing image.
needs:
- determine_environment
- test
- notify_slack

if: github.event_name == 'push'

Expand All @@ -80,24 +98,11 @@ jobs:
include:
- runner: ubuntu-latest
platform: linux/amd64
- runner: public-arm-4core
- runner: public-arm-2core
platform: linux/arm64

runs-on: ${{ matrix.runner }}
outputs:
slack_message_id: ${{ steps.slack.outputs.message_id }}
steps:
- name: Notify slack - build starting
uses: zuplo/github-action-slack-notify-build@v2
if: success()
id: slack
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel: build
status: STARTING
color: warning

- name: Prepare
run: |
platform=${{ matrix.platform }}
Expand Down Expand Up @@ -153,12 +158,12 @@ jobs:
run: docker logout

- name: Notify slack - build result failed
uses: voxmedia/github-action-slack-notify-build@v1
uses: zuplo/github-action-slack-notify-build@v2
if: failure()
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
message_id: ${{ steps.slack.outputs.message_id }}
message_id: ${{ needs.notify_slack.outputs.slack_message_id }}
channel: build
status: FAILED
color: danger
Expand All @@ -168,6 +173,7 @@ jobs:
needs:
- determine_environment
- build
- notify_slack

steps:
- name: Download digests
Expand Down Expand Up @@ -214,7 +220,7 @@ jobs:
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
message_id: ${{ needs.build.outputs.slack_message_id }}
message_id: ${{ needs.notify_slack.outputs.slack_message_id }}
channel: build
status: SUCCESS
color: good
Expand All @@ -225,7 +231,7 @@ jobs:
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
message_id: ${{ needs.build.outputs.slack_message_id }}
message_id: ${{ needs.notify_slack.outputs.slack_message_id }}
channel: build
status: FAILED
color: danger

0 comments on commit 8667263

Please sign in to comment.