Automatic pull #766
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: Automatic pull | |
on: | |
schedule: | |
- cron: '0 * * * *' | |
workflow_dispatch: # Permette di eseguire il workflow manualmente | |
permissions: | |
contents: write | |
env: | |
KBC_STORAGE_API_TOKEN: ${{ secrets.KBC_STORAGE_API_TOKEN }} | |
jobs: | |
kbc_pull: | |
# Automatic pull can be canceled by push | |
concurrency: | |
group: main_branch | |
cancel-in-progress: false | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
- name: Install Keboola as Code CLI | |
uses: ./.github/actions/install | |
with: | |
githubToken: ${{ secrets.GITHUB_TOKEN }} | |
# Pull remote project's state | |
- name: Pull from Keboola Connection | |
id: kbc_pull_step | |
run: | | |
set -eo pipefail | |
kbc pull --force 2>&1 | tee "$RUNNER_TEMP/log.txt" | |
# Automatic pull can be canceled by push, wait a while | |
- name: Wait | |
run: sleep 20 | |
# Commit message contains date and output of the pull command | |
- name: Commit and push | |
run: | | |
currentDate=`date +%Y-%m-%d:%T%Z` | |
pull_log=`cat "$RUNNER_TEMP/log.txt"` | |
git config --global user.name 'Keboola CLI' | |
git config --global user.email '[email protected]' | |
git add -A | |
git commit -a -m "Automatic pull $currentDate" -m "$pull_log" || true | |
git push |