Skip to content
Open
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
24 changes: 24 additions & 0 deletions slack-actions/workflow-notification/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,41 @@ inputs:
description: The message to display when the workflow is skipped. Accepts markdown syntax.
required: false
default: ':white_circle: Workflow skipped'
tag:
description: |
Override the commit hash displayed in the notification by resolving this tag to its commit hash.
If provided, this will be resolved to the actual commit hash.
If the tag cannot be resolved, the notification will fallback to using the current commit hash.
required: false
default: ''

runs:
using: composite
steps:
- name: Checkout repository
if: ${{ inputs.tag != '' }}
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history to ensure all tags are available

- name: Construct Slack variables
id: slack-variables
shell: bash
run: |
# Git Variables
fallbackBranchName=$(echo "${{ github.ref }}" | cut -c12-)
shortCommitHash=$(echo "${{ github.sha }}" | cut -c1-7)

# Resolve tag to commit hash if provided, otherwise use default commit hash
if [[ -n "${{ inputs.tag }}" ]]; then
if lookupCommitHashForTag=$(git rev-parse "${{ inputs.tag }}" 2>&1); then
shortCommitHash=$(echo "${lookupCommitHashForTag}" | cut -c1-7)
echo "Resolved tag '${{ inputs.tag }}' to commit hash: ${lookupCommitHashForTag}"
else
echo "Error resolving tag '${{ inputs.tag }}': ${lookupCommitHashForTag}"
echo "Falling back to current workflow commit hash: ${{ github.sha }}"
fi
fi

# Determine status message
if [[ "${{ inputs.status }}" == 'success' ]]; then
Expand Down
Loading