-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (50 loc) · 2 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Google Colab Notebook Workflow
on:
# Dispara o workflow quando há um push ou agendamento
push:
branches:
- main
schedule:
- cron: '0 * * * *' # Executa a cada hora
jobs:
execute-colab:
runs-on: ubuntu-latest
steps:
# 1. Checkout do repositório
- name: Checkout do repositório
uses: actions/checkout@v4
# 2. Autenticação para acessar o Google Colab e Google Sheets
- name: Autenticar no Google
run: |
pip install gspread oauth2client google-auth google-auth-oauthlib google-auth-httplib2
echo "Autenticando no Google para acessar o Colab e Sheets"
# 3. Conectar ao Google Colab e acessar planilha do Google Sheets
- name: Acessar Google Sheets e executar notebook do Google Colab
run: |
python - <<EOF
import gspread
from google.colab import auth
from google.auth import default
from google.colab import drive
# Autenticação no Google
auth.authenticate_user()
creds, _ = default()
gc = gspread.authorize(creds)
# Montar o Google Drive
drive.mount('/content/drive')
# Acessar a planilha do Google Sheets
spreadsheet_url = 'https://docs.google.com/spreadsheets/d/1GHn8ZSrAyi9d8kVgIfv2Yq-Cq_YD-NYaCDN15VPHO2g/edit?usp=sharing'
spreadsheet = gc.open_by_url(spreadsheet_url)
worksheet = spreadsheet.worksheet('Respostas')
# Processar os dados da planilha (exemplo: votos)
data = worksheet.get_all_records()
print("Dados processados:", data)
# Executar o notebook no Google Colab (exemplo)
notebook_url = "https://colab.research.google.com/drive/1GHn8ZSrAyi9d8kVgIfv2Yq-Cq_YD-NYaCDN15VPHO2g"
print(f"Executando notebook: {notebook_url}")
EOF
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
# 4. Notificar conclusão da execução
- name: Notificar conclusão
run: echo "Notebook executado com sucesso!"