Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ self-hosted-runner:
# Ubicloud machines we are using
labels:
- ubicloud-standard-8-arm
- ubuntu-slim
2 changes: 1 addition & 1 deletion .github/workflows/pr_pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
pre-commit:
runs-on: ubuntu-latest
runs-on: ubuntu-slim
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/smoke-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
jobs:
generate_matrix:
name: Generate Version List
runs-on: ubuntu-latest
runs-on: ubuntu-slim
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
needs: [generate_matrix, build]
permissions:
id-token: write
runs-on: ubuntu-latest
runs-on: ubuntu-slim
strategy:
matrix:
versions: ${{ fromJson(needs.generate_matrix.outputs.versions) }}
Expand All @@ -103,7 +103,7 @@ jobs:
notify:
name: Failure Notification
needs: [generate_matrix, build, publish_manifests]
runs-on: ubuntu-latest
runs-on: ubuntu-slim
if: failure() || github.run_attempt > 1
steps:
- name: Checkout Repository
Expand Down
45 changes: 21 additions & 24 deletions send-slack-notification/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,52 +80,49 @@ runs:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_WORKFLOW: ${{ github.workflow }}
GITHUB_RUN_ID: ${{ github.run_id }}
SLACK_THREAD_YAML: |
${{ steps.retrieve-slack-thread-id.outcome == 'success' && format('thread_ts: "{0}"', env.SLACK_THREAD_ID) || '' }}
CHANNEL_ID: ${{ inputs.channel-id }}
shell: bash
run: |
WORKFLOW_RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/attempts/${GITHUB_RUN_ATTEMPT}"
echo "WORKFLOW_RUN_URL=$WORKFLOW_RUN_URL" | tee -a "$GITHUB_ENV"
export WORKFLOW_RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/attempts/${GITHUB_RUN_ATTEMPT}"

if [ "$NOTIFICATION_TYPE" == "container-image-build" ]; then
# TODO (@Techassi): Also add success template
if [ "$PUBLISH_MANIFESTS_RESULT" = "failure" ] || [ "$BUILD_RESULT" = "failure" ]; then
MESSAGE_VERB=failed
echo "MESSAGE_VERB=$MESSAGE_VERB" | tee -a "$GITHUB_ENV"

echo "MESSAGE_COLOR=aa0000" | tee -a "$GITHUB_ENV"
export MESSAGE_VERB=failed
export MESSAGE_COLOR=aa0000
else
MESSAGE_VERB=succeeded
echo "MESSAGE_VERB=$MESSAGE_VERB" | tee -a "$GITHUB_ENV"

echo "MESSAGE_COLOR=10c400" | tee -a "$GITHUB_ENV"
export MESSAGE_VERB=succeeded
export MESSAGE_COLOR=10c400
fi

echo "MESSAGE_TEXT=*$GITHUB_WORKFLOW* $MESSAGE_VERB (attempt $GITHUB_RUN_ATTEMPT)" | tee -a "$GITHUB_ENV"
echo -e "MESSAGE_TEMPLATE<<EOF\n$(cat ${GITHUB_ACTION_PATH}/templates/container-image-build/failure.tpl)\nEOF" | tee -a "$GITHUB_ENV"
export MESSAGE_TEXT="*$GITHUB_WORKFLOW* $MESSAGE_VERB (attempt $GITHUB_RUN_ATTEMPT)"
PAYLOAD=$(envsubst < "${GITHUB_ACTION_PATH}/templates/container-image-build/failure.tpl")
echo -e "PAYLOAD<<EOF\n$PAYLOAD\nEOF" | tee -a "$GITHUB_ENV"
elif [ "$NOTIFICATION_TYPE" == "integration-test" ]; then
echo "HEALTH_SLACK_EMOJI=$(echo "$TEST_HEALTH" | cut -d ',' -f 1)" | tee -a "$GITHUB_ENV"
echo "HEALTH_RATE=$(echo "$TEST_HEALTH" | cut -d ',' -f 3)" | tee -a "$GITHUB_ENV"
export HEALTH_SLACK_EMOJI=$(echo "$TEST_HEALTH" | cut -d ',' -f 1)
export HEALTH_RATE=$(echo "$TEST_HEALTH" | cut -d ',' -f 3)

if [ "$TEST_RESULT" == "failure" ]; then
echo "MESSAGE_TEXT=The integration test for *`$GITHUB_REPOSITORY`* failed." | tee -a "$GITHUB_ENV"
echo -e "MESSAGE_TEMPLATE<<EOF\n$(cat ${GITHUB_ACTION_PATH}/templates/integration-test/failure.tpl)\nEOF" | tee -a "$GITHUB_ENV"
export MESSAGE_TEXT="The integration test for *`$GITHUB_REPOSITORY`* failed."
PAYLOAD=$(envsubst < "${GITHUB_ACTION_PATH}/templates/integration-test/failure.tpl")
echo -e "PAYLOAD<<EOF\n$PAYLOAD\nEOF" | tee -a "$GITHUB_ENV"
else
echo "MESSAGE_TEXT=The integration test for *`$GITHUB_REPOSITORY`* succeeded." | tee -a "$GITHUB_ENV"
echo -e "MESSAGE_TEMPLATE<<EOF\n$(cat ${GITHUB_ACTION_PATH}/templates/integration-test/success.tpl)\nEOF" | tee -a "$GITHUB_ENV"
export MESSAGE_TEXT="The integration test for *`$GITHUB_REPOSITORY`* succeeded."
PAYLOAD=$(envsubst < "${GITHUB_ACTION_PATH}/templates/integration-test/success.tpl")
echo -e "PAYLOAD<<EOF\n$PAYLOAD\nEOF" | tee -a "$GITHUB_ENV"
fi
fi

- name: Send Notification
id: send-notification
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # 2.1.1
env:
SLACK_THREAD_YAML: |
${{ steps.retrieve-slack-thread-id.outcome == 'success' && format('thread_ts: "{0}"', env.SLACK_THREAD_ID) || '' }}
CHANNEL_ID: ${{ inputs.channel-id }}
with:
method: chat.postMessage
token: ${{ inputs.slack-token }}
payload: ${{ env.MESSAGE_TEMPLATE }}
payload-templated: true
payload: ${{ env.PAYLOAD }}
payload-templated: false

- name: Save Slack Thread ID to File
if: steps.retrieve-slack-thread-id.outcome == 'failure'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
channel: "${{ env.CHANNEL_ID }}"
text: "${{ env.MESSAGE_TEXT }}"
${{ env.SLACK_THREAD_YAML }}
channel: "${CHANNEL_ID}"
text: "${MESSAGE_TEXT}"
${SLACK_THREAD_YAML}
attachments:
- pretext: "See the details below for a summary of which job(s) ${{ env.MESSAGE_VERB }}."
color: "${{ env.MESSAGE_COLOR }}"
- pretext: "See the details below for a summary of which job(s) ${MESSAGE_VERB}."
color: "${MESSAGE_COLOR}"
fields:
- title: Build/Publish Image
short: true
value: "${{ env.BUILD_RESULT }}"
value: "${BUILD_RESULT}"
- title: Build/Publish Manifests
short: true
value: "${{ env.PUBLISH_MANIFESTS_RESULT }}"
value: "${PUBLISH_MANIFESTS_RESULT}"
actions:
- type: button
text: Go to workflow run
url: "${{ env.WORKFLOW_RUN_URL }}"
url: "${WORKFLOW_RUN_URL}"
12 changes: 6 additions & 6 deletions send-slack-notification/templates/integration-test/failure.tpl
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
channel: "${{ env.CHANNEL_ID }}"
${{ env.SLACK_THREAD_YAML }}
channel: "${CHANNEL_ID}"
${SLACK_THREAD_YAML}
blocks:
- type: "section"
text:
type: "mrkdwn"
text: "${{ env.MESSAGE_TEXT }}"
text: "${MESSAGE_TEXT}"
- type: "section"
text:
type: "mrkdwn"
text: "${{ env.HEALTH_SLACK_EMOJI }} (${{ env.HEALTH_RATE }}) The integration test failed because of the following individual tests:"
text: "${HEALTH_SLACK_EMOJI} (${HEALTH_RATE}) The integration test failed because of the following individual tests:"
- type: "rich_text"
elements:
- type: "rich_text_preformatted"
elements:
- type: "text"
text: "${{ env.FAILED_TESTS }}"
text: "${FAILED_TESTS}"
- type: "actions"
elements:
- type: button
text:
type: "plain_text"
text: "View Workflow Run"
emoji: false
url: "${{ env.WORKFLOW_RUN_URL }}"
url: "${WORKFLOW_RUN_URL}"
- type: button
text:
type: "plain_text"
Expand Down
10 changes: 5 additions & 5 deletions send-slack-notification/templates/integration-test/success.tpl
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
channel: "${{ env.CHANNEL_ID }}"
${{ env.SLACK_THREAD_YAML }}
channel: "${CHANNEL_ID}"
${SLACK_THREAD_YAML}
blocks:
- type: "section"
text:
type: "mrkdwn"
text: "${{ env.MESSAGE_TEXT }}"
text: "${MESSAGE_TEXT}"
- type: "section"
text:
type: "mrkdwn"
text: "${{ env.HEALTH_SLACK_EMOJI }} (${{ env.HEALTH_RATE }}) The integration test for *${{ github.repository }}* succeeded."
text: "${HEALTH_SLACK_EMOJI} (${HEALTH_RATE}) The integration test for *${{ github.repository }}* succeeded."
- type: "actions"
elements:
- type: button
text:
type: "plain_text"
text: "View Workflow Run"
emoji: false
url: "${{ env.WORKFLOW_RUN_URL }}"
url: "${WORKFLOW_RUN_URL}"
- type: button
text:
type: "plain_text"
Expand Down
Loading