Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gha test workflow #74

Merged
merged 14 commits into from
Jul 16, 2024
Merged
51 changes: 40 additions & 11 deletions .github/workflows/update-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: main
branches-ignore:
- main
pull_request:
branches: main
types:
- opened
- synchronize
branches-ignore:
- main

name: cicd

Expand All @@ -15,7 +20,22 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
steps:
- uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Check commit message
id: check_commit_message
run: |
COMMIT_MSG=$(git log -1 --pretty=%B)
if [[ "$COMMIT_MSG" != "Update data"* ]]; then
echo "Commit message does not start with 'Update data'."
echo "result=0" >> $GITHUB_ENV
else
echo "result=1" >> $GITHUB_ENV
fi

- uses: r-lib/actions/setup-r@v2
with:
Expand All @@ -34,36 +54,45 @@ jobs:
- uses: r-lib/actions/check-r-package@v2

- name: Update data
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
if: env.result == '1'
env:
HOADDATA_PASSWORD: ${{ secrets.HOADDATA_PASSWORD }}
run: |
source("data-raw/jct_001_get_cr_data.R")
shell: Rscript {0}

- name: Check package after data update
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
if: env.result == '1'
uses: r-lib/actions/check-r-package@v2

- name: Commit files
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
if: env.result == '1'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit --allow-empty -m "Auto-update of the data package" -a
DATE=$(date +'%Y-%m-%d %H:%M:%S')
git add data/
git commit --allow-empty -m "Auto-update of the data package on $DATE" -a

- name: Update branch
if: env.result == '1'
run: |
git pull --rebase origin ${{ github.head_ref }}

- name: Push changes
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
if: env.result == '1'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN}}
branch: ${{ github.head_ref }} # Push changes back to the originating branch
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Build site
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
uses: JamesIves/[email protected]
with:
clean: false
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: hoaddata
Type: Package
Title: Data about hybrid open access journal publishing
Version: 0.2.97
Version: 0.2.98
Authors@R:
person("Najko", "Jahn", , "[email protected]",
role = c("aut", "cre"),
Expand Down
Loading
Loading