Act on release #9
This file contains 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: Act on release | |
on: | |
workflow_call: | |
inputs: | |
release_tag: | |
type: string | |
description: 'The tag of the release' | |
required: true | |
workflow_dispatch: | |
inputs: | |
release_tag: | |
type: string | |
description: 'The tag of the release' | |
required: false | |
type: | |
type: choice | |
description: 'The type of action to perform' | |
required: true | |
options: | |
- Release Notification | |
- Custom Notification | |
title: | |
type: string | |
description: 'The title of the notification' | |
required: false | |
body: | |
type: string | |
description: 'The body of the notification' | |
required: false | |
jobs: | |
push_notification: | |
name: Push Notification | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' # The python version to use. | |
cache: 'pip' | |
cache-dependency-path: 'push-notify/requirements.txt' | |
- name: Install dependencies | |
run: pip install -r push-notify/requirements.txt | |
- name: Create google-auth json | |
run: echo "${{ secrets.GOOGLE_AUTH_JSON }}" | base64 -d > google-services.json | |
- name: Run push notification script | |
if: ${{ inputs.release_tag }} | |
run: | | |
release_tag="${{ inputs.release_tag }}" | |
release_body=$(gh release view $release_tag --json body -q .body) | |
python3 push-notify --title "App update $release_tag" --body "$release_body" --api_url ${{ secrets.NOTIF_API_URL }} --bearer ${{ secrets.NOTIF_API_BEARER }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Run custom notification script | |
if: ${{ github.event.inputs.type == 'Custom Notification' && inputs.title && inputs.body }} | |
run: | | |
python3 push-notify --title "${{ inputs.title }}" --body "${{ inputs.body }}" --api_url ${{ secrets.NOTIF_API_URL }} --bearer ${{ secrets.NOTIF_API_BEARER }} |