Skip to content

init banner

init banner #1083

Workflow file for this run

name: init banner
on:
workflow_dispatch:
schedule:
- cron: "0 */2 * * *"
permissions:
contents: write
actions: read
jobs:
init:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Necessary for GH CLI
FB_TOKEN: ${{ secrets.FB_TOKEN }} # Your Facebook token
steps:
# -------------------------------------------------------------
# CHECKOUT
# -------------------------------------------------------------
- name: Checkout
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0 # Essential to the auto-commit function
persist-credentials: true # Keeps the token to make git push
# -------------------------------------------------------------
# PYTHON
# -------------------------------------------------------------
- name: Set up Python
uses: actions/setup-python@v5.4.0
with:
python-version: "3.13"
# -------------------------------------------------------------
# CHECK IF THE WORKFLOW IS ALREADY RUNNING
# -------------------------------------------------------------
- name: Is it already running?
run: |
WORKFLOW_NAME="${{ github.workflow }}"
RUN_COUNT=$(gh run list \
--status=in_progress \
--json name \
--jq "[.[] | select(.name == \"$WORKFLOW_NAME\")] | length")
echo "Workflows in progress: $RUN_COUNT"
if [ "$RUN_COUNT" -gt 1 ]; then
echo "IS_RUNNING=true" >> $GITHUB_ENV
else
echo "IS_RUNNING=false" >> $GITHUB_ENV
fi
# -------------------------------------------------------------
# CACHE DEPENDENCIES (Python)
# -------------------------------------------------------------
- name: Cache dependencies
uses: actions/cache@v4.2.0
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# -------------------------------------------------------------
# INSTALL PYTHON DEPENDENCIES
# -------------------------------------------------------------
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# -------------------------------------------------------------
# EXECUTION OF MAIN ONLY IF THE WORKFLOW IS NOT RUNNING
# -------------------------------------------------------------
- name: Main
run: |
if [[ "$IS_RUNNING" == "false" ]]; then
python main.py
else
echo "Workflow is already running. Skipping execution."
fi
# -------------------------------------------------------------
# AUTO COMMIT (GitHub Actions)
# -------------------------------------------------------------
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: "logs/* configs.yml"
commit_message: "Update"
commit_user_name: "GitHub Actions"
commit_user_email: "actions@github.com"
commit_author: "GitHub Actions <actions@github.com>"
skip_dirty_check: true