Auto Commit #16
This file contains hidden or 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: Auto Commit | |
on: | |
schedule: | |
- cron: "0 0 * * *" # Executa diariamente à meia-noite UTC | |
workflow_dispatch: # Permite execução manual | |
jobs: | |
auto-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout do repositório | |
uses: actions/checkout@v3 | |
- name: Configurar Git | |
run: | | |
git config --global user.name "EduardoDosSantosFerreira" | |
git config --global user.email "[email protected]" | |
- name: Obter próximo update | |
id: update | |
run: | | |
LAST_UPDATE=$(git branch -r | grep -oE 'update' | sort -V | tail -n1) | |
if [ -z "$LAST_UPDATE" ]; then | |
NEXT_UPDATE="update" # Começa com "update" se não houver registros | |
else | |
NEXT_UPDATE="update" | |
fi | |
echo "NEXT_UPDATE=$NEXT_UPDATE" >> $GITHUB_ENV | |
- name: Configurar URL Remota para usar o Token | |
run: | | |
git remote set-url origin https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/EduardoDosSantosFerreira/Portfolio.git | |
- name: Commit e Push | |
run: | | |
git pull origin main | |
git add . | |
git commit -m "Atualização automática: ${{ env.NEXT_UPDATE }} - $(date +'%Y-%m-%d %H:%M:%S')" || exit 0 | |
git push origin main |