Pull the Github Actions trigger #8
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: Run Selenium Java application built with Maven | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
schedule: | |
- cron: '0 12 * * *' # it will be 6 am in our timezone | |
jobs: | |
run-selenium-script: | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
# Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
# Set up Java 11 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v2 | |
with: | |
distribution: "temurin" | |
java-version: "11" | |
# Set up Chrome browser (pre-installed on GitHub runners) | |
- name: Set up Chrome browser | |
run: google-chrome --version | |
# Cache Maven dependencies (improves build times) | |
- name: Cache Maven dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
# Install dependencies with Maven | |
- name: Build with Maven | |
run: mvn install | |
# Run Selenium script using Maven and Send Telegram notification | |
- name: Run Selenium script & Notify via Telegram | |
run: | | |
mvn exec:java -Dexec.mainClass="eclass.kr.DeadlineNotifier" > OUTPUT.txt | |
curl -s -X POST https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage -d chat_id=${{ secrets.TELEGRAM_CHAT_ID }} -d text="$(sed -n '/Today/,/^Bye/{/^Bye/d;p}' OUTPUT.txt)" | |
env: | |
ID: ${{ secrets.ID }} | |
PASSWORD: ${{ secrets.PASSWORD }} |