Update Data #455
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: Update Data | |
on: | |
schedule: | |
- cron: '0 0 1 * *' | |
workflow_dispatch: # Or manually from GitHub UI | |
jobs: | |
autoupdate: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: r-lib/actions/setup-r@v2 | |
- name: Install packages | |
run: | | |
R -e 'install.packages(c("devtools", "countrycode", "dplyr", "maps", "rjson", "stringdist", "usethis", "utils"))' | |
R -e 'devtools::install(".")' | |
- name: Set credentials | |
run: | | |
git config --global user.email "actions@github.com" | |
git config --global user.name actions-user | |
- name: Check for existing branch | |
run: | | |
if (( $(git ls-remote --heads origin refs/heads/data-update | wc -l) == 1 )); then | |
echo deleting existing branch | |
git push origin --delete data-update | |
else | |
echo no existing branch found | |
fi | |
- name: Update data | |
run: | | |
git branch data-update | |
git checkout data-update | |
Rscript Scripts/auto-update.R | |
- name: Commit, push and open new PR with changes (if any) | |
run: | | |
if [[ `git status --porcelain` ]]; then | |
git commit -a -m 'data update' | |
git push --set-upstream origin data-update | |
gh pr create --base main --head data-update --title 'Automated data update' --body 'Automated Data Update' | |
else | |
echo No auction changes detected, skipping update. | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |