Skip to content

Instantly share code, notes, and snippets.

@fragaLY
Created October 8, 2021 12:02
Show Gist options
  • Save fragaLY/b302626e4ab7356a4300bdc0f1eda772 to your computer and use it in GitHub Desktop.
Save fragaLY/b302626e4ab7356a4300bdc0f1eda772 to your computer and use it in GitHub Desktop.
Github Actions with Telegram Notification Example
name: ci
on:
push:
branches:
- main
- develop
- 'feature/**'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: ${{ secrets.JAVA_VERSION_16 }}
distribution: 'adopt'
architecture: x64
- name: Preparation
run: chmod +x gradlew
- name: Tests
run: ./gradlew test --parallel
build:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: ${{ secrets.JAVA_VERSION_16 }}
distribution: 'adopt'
architecture: x64
- name: Preparation
run: chmod +x gradlew
- name: Build
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
run: ./gradlew build -x test --parallel -Djib.to.image=${{ secrets.DOCKER_HUB_REGISTRY }}/${{ secrets.DOCKER_HUB_USER }}/challenger-api:latest -Djib.to.auth.username=${{ secrets.DOCKER_HUB_USER }} -Djib.to.auth.password=${{ secrets.DOCKER_HUB_PASSWORD }}
notification:
runs-on: ubuntu-latest
needs: build
steps:
- name: Telegram notification
uses: appleboy/telegram-action@master
if: always()
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
args: ${{github.repository}} - a ${{ github.event_name }} to ${{ github.ref }} triggered by ${{ github.actor }} has status ${{ job.status }}.
name: notification
on:
pull_request:
branches:
- main
- develop
- 'feature/*'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: ${{ secrets.JAVA_VERSION_16 }}
distribution: 'adopt'
architecture: x64
- name: Preparation
run: chmod +x gradlew
- name: Tests
run: ./gradlew test --parallel
notification:
runs-on: ubuntu-latest
needs: test
steps:
- name: Telegram notification
uses: appleboy/telegram-action@master
if: always()
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
document: /home/runner/work/challenger-backend/challenger-backend/build/reports/tests/test/index.html
args: ${{github.repository}} - a new ${{ github.event_name}} from [${{github.head_ref}}] to [${{github.base_ref}}] is created by ${{github.actor}}. Please review ${{github.event.pull_request.html_url}}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment