Skip to content

Commit

Permalink
Prepare for deploy from GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mhalbritter committed Mar 12, 2024
1 parent ab53c29 commit 2717f4e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 10 deletions.
30 changes: 30 additions & 0 deletions .github/actions/send-notification/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Send notification
description: Sends a Google Chat message as a notification of the job's outcome
inputs:
webhook-url:
description: 'Google Chat Webhook URL'
required: true
status:
description: 'Status of the job'
required: true
run-name:
description: 'Name of the run to include in the notification'
default: ${{ format('{0} {1}', github.ref_name, github.job) }}
runs:
using: composite
steps:
- shell: bash
run: |
echo "RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> "$GITHUB_ENV"
- shell: bash
if: ${{ inputs.status == 'success' }}
run: |
curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<${{ env.RUN_URL }}|${{ inputs.run-name }}> was successful"}' || true
- shell: bash
if: ${{ inputs.status == 'failure' }}
run: |
curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<users/all> *<${{ env.RUN_URL }}|${{ inputs.run-name }}> failed* "}' || true
- shell: bash
if: ${{ inputs.status == 'cancelled' }}
run: |
curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<${{ env.RUN_URL }}|${{ inputs.run-name }}> was cancelled"}' || true
33 changes: 23 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@ on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
strategy:
matrix:
runner: [ ubuntu-latest, windows-latest, macos-latest ]
name: Build (${{ matrix.runner }})
runner:
- os: ubuntu-latest
name: Linux
deploy-snapshots: true
- os: windows-latest
name: Windows
deploy-snapshots: false
- os: macos-latest
name: MacOS
deploy-snapshots: false
name: Build (${{ matrix.runner.name }})
if: ${{ github.repository == 'spring-io/initializr' }}
runs-on: ${{ matrix.runner }}
runs-on: ${{ matrix.runner.os }}
steps:
- name: Check out
uses: actions/checkout@v4
Expand All @@ -26,13 +34,18 @@ jobs:
distribution: 'liberica'
cache: 'maven'

- name: Build with Maven
- name: Maven verify
if: ${{ !matrix.runner.deploy-snapshots }}
run: ./mvnw --no-transfer-progress --batch-mode --update-snapshots verify

- name: Google Chat Notification
uses: Co-qn/google-chat-notification@3691ccf4763537d6e544bc6cdcccc1965799d056
- name: Maven deploy
if: ${{ matrix.runner.deploy-snapshots }}
run: echo "Would deploy"

- name: Send notification
uses: ./.github/actions/send-notification
if: always()
with:
name: Build (${{ matrix.runner }})
url: ${{ secrets.GOOGLE_CHAT_WEBHOOK }}
webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK }}
status: ${{ job.status }}
if: always()
run-name: ${{ format('{0} | {1}', github.ref_name, matrix.runner.name) }}

0 comments on commit 2717f4e

Please sign in to comment.