Skip to content

Update index.html

Update index.html #41

Workflow file for this run

name: Update index.html
on:
schedule:
- cron: "0 0 * * 0" # Runs every Sunday at midnight UTC
push:
branches:
- master # Trigger the workflow on push to the master branch
jobs:
update-index:
runs-on: ubuntu-latest
steps:
- name: Checkout rubenpp7.github.io repo
uses: actions/checkout@v4
with:
ref: master
- name: Set up R environment
uses: r-lib/actions/setup-r@v2
- name: Install pandoc
uses: r-lib/actions/setup-pandoc@v2
- name: Install system dependencies for sf
run: |
sudo apt-get update && sudo apt-get install -y libgeos-dev libproj-dev gdal-bin libgdal-dev libudunits2-dev
- name: Install remotes and R dependencies for Divewatchr
env:
GITHUB_PAT: ${{ secrets.PAT_GITHUB }} # Use your PAT from GitHub Secrets
run: |
# Install remotes if it's not installed yet
R -e 'if (!requireNamespace("remotes", quietly = TRUE)) install.packages("remotes")'
# Install the R dependencies for Divewatchr
R -e 'install.packages(c("googlesheets4", "leaflet", "sf", "usethis", "gargle"), repos = "https://cloud.r-project.org")'
# Install the Divewatchr package
R -e 'remotes::install_github("rubenpp7/divewatchr")'
- name: Set up Google OAuth token & Run R function from Divewatchr
run: |
mkdir -p ~/.config/gcloud/
pwd
ls
echo "${{ secrets.GOOGLE_OAUTH_TOKEN_BASE64 }}" | base64 --decode > ~/.config/gcloud/google-oauth-token.rds
if [ -f ~/.config/gcloud/google-oauth-token.rds ]; then
echo "Token file exists."
else
echo "Token file is missing!" && exit 1
fi
cd ~
Rscript -e 'library(divewatchr); divewatch(data = "1qO7_0K1R-4i_MSgtT3zAYbZfxBmPMgQWAi7OmWmb1-M")'
find . -name "overview.html"
mv ./overview.html /home/runner/work/rubenpp7.github.io/rubenpp7.github.io
- name: Rename old index.html
run: |
if [ -f "index.html" ]; then
mv index.html index_old.html
fi
- name: Rename output.html to index.html
run: |
if [ -f "overview.html" ]; then
mv -f overview.html index.html
fi
- name: Commit changes
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add index.html index_old.html
git commit -m "Update index.html and rename old file"
- name: Push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}