LFL Lab Manager #48
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: LFL Lab Manager | |
on: | |
schedule: | |
- cron: '0 14 * * *' # This sets the job to run at 2:00 PM UTC every day, which is 7:00 AM PDT | |
workflow_dispatch: # Allows manual trigger | |
jobs: | |
run-lab-manager: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.8' | |
- name: Cache pip dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Decrypt client_secret.json | |
env: | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
run: | | |
openssl aes-256-cbc -salt -a -d -in client_secret.json.enc -out client_secret.json -pass pass:$SECRET_KEY -pbkdf2 | |
- name: Decrypt token.pickle | |
env: | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
run: | | |
openssl aes-256-cbc -salt -a -d -in token.pickle.enc -out token.pickle -pass pass:$SECRET_KEY -pbkdf2 | |
- name: Decrypt service_key.json | |
env: | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
run: | | |
openssl aes-256-cbc -salt -a -d -in service_key.json.enc -out service_key.json -pass pass:$SECRET_KEY -pbkdf2 | |
- name: Decrypt lab_members.json | |
env: | |
SECRET_KEY: ${{ secrets.SECRET_KEY_LAB }} | |
run: | | |
openssl aes-256-cbc -salt -a -d -in lab_members.json.enc -out lab_members.json -pass pass:$SECRET_KEY_LAB -pbkdf2 | |
- name: Run the lab manager script | |
env: | |
GMAIL_USERNAME: ${{ secrets.GMAIL_USERNAME }} | |
GMAIL_PASSWORD: ${{ secrets.GMAIL_PASSWORD }} | |
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }} | |
ONENOTE_LCD: ${{ secrets.ONENOTE_LCD }} | |
run: | | |
python main.py | |
- name: Check for changes | |
id: changes | |
run: | | |
git diff --exit-code || echo "has_changes=true" >> $GITHUB_ENV | |
- name: Commit and push if there are changes | |
if: env.has_changes == 'true' | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add duty_tracker.json | |
git commit -m "Updating the duty_tracker.json - $(date)" | |
git push | |
env: | |
GIT_AUTHOR_EMAIL: action@github.com | |
GIT_COMMITTER_EMAIL: action@github.com | |
GIT_HTTPS_USERNAME: shanto268 # update this | |
GIT_HTTPS_PASSWORD: ${{secrets.GH_BOT}} # update this |