Release automation: release/8.0 #74
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | |
on: | |
pull_request: | |
branches: | |
- master | |
- release/* | |
workflow_call: | |
inputs: | |
release_tag: | |
description: 'Release tag to build' | |
required: true | |
type: string | |
outputs: | |
docker_image_urls: | |
description: 'Array of Docker image URLs that were published' | |
value: ${{ jobs.collect-image-urls.outputs.docker_image_urls }} | |
jobs: | |
build-and-test: | |
runs-on: ${{ contains(matrix.platform, 'arm64') && 'ubuntu24-arm64-2-8' || 'ubuntu-latest' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
distribution: | |
- debian | |
- alpine | |
platform: | |
- linux/amd64 | |
- linux/i386 | |
- linux/arm/v5 | |
- linux/arm/v6 | |
- linux/arm/v7 | |
- linux/mips64le | |
- linux/ppc64le | |
- linux/s390x | |
- linux/arm64 | |
- linux/riscv64 | |
exclude: | |
- distribution: alpine | |
platform: linux/mips64le | |
- distribution: alpine | |
platform: linux/arm/v5 | |
- distribution: debian | |
platform: linux/riscv64 | |
- distribution: debian | |
platform: linux/arm/v6 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Ensure release branch | |
if: ${{ inputs.release_tag }} | |
uses: redis/redis-oss-release-automation/.github/actions/ensure-release-branch@main | |
with: | |
release_tag: ${{ inputs.release_tag }} | |
gh_token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: ./.github/actions/build-and-tag-locally | |
with: | |
distribution: ${{ matrix.distribution }} | |
platform: ${{ matrix.platform }} | |
registry_username: ${{ github.actor }} | |
registry_password: ${{ secrets.GITHUB_TOKEN }} | |
publish_image: ${{ vars.PUBLISH_IMAGE }} | |
registry_repository: ${{ format('ghcr.io/{0}', github.repository) }} | |
release_tag: ${{ inputs.release_tag }} | |
collect-image-urls: | |
runs-on: ubuntu-latest | |
needs: build-and-test | |
if: ${{ inputs.release_tag }} | |
outputs: | |
docker_image_urls: ${{ steps.collect-urls.outputs.urls }} | |
steps: | |
- name: Download all image URL artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: image-url-* | |
path: ./image-urls | |
merge-multiple: true | |
- name: Collect image URLs from artifacts | |
id: collect-urls | |
run: | | |
if [ -d "./image-urls" ] && [ "$(ls -A ./image-urls 2>/dev/null)" ]; then | |
echo "Found image URL files:" | |
urls=$(find ./image-urls -name "*.txt" -exec cat {} \; | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
echo "Collected image URLs: $urls" | |
else | |
echo "No image URL artifacts found" | |
urls="[]" | |
fi | |
echo "urls=$urls" >> "$GITHUB_OUTPUT" | |
notify-slack: | |
runs-on: ubuntu-latest | |
needs: collect-image-urls | |
if: ${{ inputs.release_tag && needs.collect-image-urls.outputs.docker_image_urls != '[]' }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Send Slack notification | |
run: | | |
image_urls='${{ needs.collect-image-urls.outputs.docker_image_urls }}' | |
workflow_url="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
footer="Repository: ${{ github.repository }} | Commit: \`${{ github.sha }}\` | View: <$workflow_url|workflow run>" | |
. ${GITHUB_WORKSPACE}/.github/actions/common/func.sh | |
echo "$image_urls" | slack_format_docker_image_urls_message "${{ inputs.release_tag }}" "$footer" \ | |
| curl -s --fail-with-body -d@- "${{ secrets.SLACK_WEB_HOOK_URL }}" | |
notify-slack-when-failed: | |
runs-on: ubuntu-latest | |
needs: collect-image-urls | |
if: ${{ inputs.release_tag && failure() }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Send Failure Slack notification | |
run: | | |
workflow_url="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
footer="Repository: ${{ github.repository }} | Commit: \`${{ github.sha }}\`" | |
. ${GITHUB_WORKSPACE}/.github/actions/common/func.sh | |
slack_format_failure_message "Docker Build failed for Redis: ${{ inputs.release_tag || 'unknown'}}" "$workflow_url" "$footer" \ | |
| curl -s --fail-with-body -d@- "${{ secrets.SLACK_WEB_HOOK_URL }}" |