Skip to content

Commit e325c91

Browse files
committed
ci: update 01 workflow configuration
1 parent 4029cc8 commit e325c91

File tree

1 file changed

+40
-26
lines changed

1 file changed

+40
-26
lines changed

.github/workflows/01.yml

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,83 +3,97 @@ name: init banner
33
on:
44
workflow_dispatch:
55
schedule:
6-
# You can change this CRON syntax to customize execute interval
76
- cron: "0 */3 * * *"
87

9-
108
permissions:
119
contents: write
12-
actions: write
10+
actions: read
1311

1412
jobs:
1513
init:
1614
runs-on: ubuntu-latest
1715

1816
env:
19-
20-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub Token for CLI
21-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub Token for Actions
22-
FB_TOKEN: ${{ secrets.FB_TOKEN }} # Facebook Token
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Necessary for GH CLI
18+
FB_TOKEN: ${{ secrets.FB_TOKEN }} # Your Facebook token
2319

2420
steps:
21+
# -------------------------------------------------------------
22+
# CHECKOUT
23+
# -------------------------------------------------------------
2524
- name: Checkout
2625
uses: actions/checkout@v4.2.2
26+
with:
27+
fetch-depth: 0 # Essential to the auto-commit function
28+
persist-credentials: true # Keeps the token to make git push
2729

30+
# -------------------------------------------------------------
31+
# PYTHON
32+
# -------------------------------------------------------------
2833
- name: Set up Python
2934
uses: actions/setup-python@v5.4.0
3035
with:
3136
python-version: "3.13"
32-
33-
# checa se o workflow já está rodando, atribui o valor para a variável IS_RUNNING
37+
38+
# -------------------------------------------------------------
39+
# CHECK IF THE WORKFLOW IS ALREADY RUNNING
40+
# -------------------------------------------------------------
3441
- name: Is it already running?
3542
run: |
3643
WORKFLOW_NAME="${{ github.workflow }}"
37-
RUN_COUNT=$(gh run list --status=in_progress --json name |
38-
jq "[.[] | select(.name == \"$WORKFLOW_NAME\")] | length")
39-
44+
45+
RUN_COUNT=$(gh run list \
46+
--status=in_progress \
47+
--json name \
48+
--jq "[.[] | select(.name == \"$WORKFLOW_NAME\")] | length")
49+
50+
echo "Workflows in progress: $RUN_COUNT"
51+
4052
if [ "$RUN_COUNT" -gt 1 ]; then
41-
echo "The workflow init banner is already running"
4253
echo "IS_RUNNING=true" >> $GITHUB_ENV
4354
else
4455
echo "IS_RUNNING=false" >> $GITHUB_ENV
4556
fi
46-
47-
# checa se o episódio está disponível, se não, sai do workflow com erro
48-
# - name: Check if episode is available
49-
# run: |
50-
5157
52-
# cache de dependencias
58+
# -------------------------------------------------------------
59+
# CACHE DEPENDENCIES (Python)
60+
# -------------------------------------------------------------
5361
- name: Cache dependencies
5462
uses: actions/cache@v4.2.0
5563
with:
5664
path: ~/.cache/pip
5765
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
5866
restore-keys: |
5967
${{ runner.os }}-pip-
60-
${{ runner.os }}-
6168
62-
# instala dependencias
69+
# -------------------------------------------------------------
70+
# INSTALL PYTHON DEPENDENCIES
71+
# -------------------------------------------------------------
6372
- name: Install dependencies
6473
run: |
6574
python -m pip install --upgrade pip
6675
pip install -r requirements.txt
6776
68-
# So roda o main.py se o workflow não estiver rodando
77+
# -------------------------------------------------------------
78+
# EXECUTION OF MAIN ONLY IF THE WORKFLOW IS NOT RUNNING
79+
# -------------------------------------------------------------
6980
- name: Main
7081
run: |
7182
if [[ "$IS_RUNNING" == "false" ]]; then
7283
python main.py
84+
else
85+
echo "Workflow is already running. Skipping execution."
7386
fi
74-
7587
76-
# atualiza variaveis que serão usadas no próximo workflow
88+
# -------------------------------------------------------------
89+
# AUTO COMMIT (GitHub Actions)
90+
# -------------------------------------------------------------
7791
- name: Commit changes
7892
uses: stefanzweifel/git-auto-commit-action@v5
7993
with:
80-
file_pattern: "logs/* configs.yml"
94+
file_pattern: "logs/* configs.yml"
8195
commit_message: "Update"
8296
commit_user_name: "GitHub Actions"
8397
commit_user_email: "actions@github.com"
8498
commit_author: "GitHub Actions <actions@github.com>"
85-
skip_dirty_check: true
99+
skip_dirty_check: true

0 commit comments

Comments
 (0)