Skip to content

Change pwd brackets #365

Change pwd brackets

Change pwd brackets #365

Workflow file for this run

name: build
on:
pull_request:
branches:
- main
workflow_dispatch:
push:
branches:
- 'main'
- 'test-build'
- 'docker-build'
tags:
- "v*"
env:
PARTICIPANT_DATA:
REGISTRY: ghcr.io
ORG: nbisweden
IMAGE: workshop-pgip/workshop-pgip:latest
jobs:
build:
runs-on: ubuntu-latest
name: Build site
timeout-minutes: 60
permissions:
contents: write
defaults:
run:
shell: bash -l {0}
steps:
- name: Set time zone
uses: szenius/set-timezone@v1.0
with:
timezoneLinux: "Europe/Stockholm"
timezoneMacos: "Europe/Stockholm"
timezoneWindows: "W. Europe Standard Time"
- name: Cancel Previous Runs
if: ${{ !env.ACT }}
uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ github.token }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Pull image
run: docker pull ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}
- name: Define variables
run: |
echo "REPO=$(basename ${GITHUB_REPOSITORY})" >> $GITHUB_ENV
cd docs
echo "PATH_REPO=$(pwd)" >> $GITHUB_ENV
echo "PATH_EXPORT=$(grep -E 'output-dir' _quarto.yml | xargs | sed 's/output-dir://' | xargs)" >> $GITHUB_ENV
- name: Check docker and variables
run: |
docker run --rm -u $(id -u ${USER}):$(id -g ${USER}) -v ${PWD}:/qmd ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }} Rscript -e "print('R in docker works!')"
echo "GITHUB_ACTOR: ${GITHUB_ACTOR}"
echo "GITHUB_REPOSITORY: ${GITHUB_REPOSITORY}"
echo "REPO: ${REPO}"
echo "env.PATH_REPO: ${{ env.PATH_REPO }}"
echo "PATH_EXPORT: ${PATH_EXPORT}"
echo "PATH_EXPORT_CANVAS: ${PATH_EXPORT_CANVAS}"
echo "GITHUB_REPOSITORY_OWNER: ${GITHUB_REPOSITORY_OWNER}"
echo "---------------------------------------------------------------------------------------------"
echo "Folder contents at $(pwd):"
ls -lh
echo "---------------------------------------------------------------------------------------------"
printenv
sed --version
- name: Render site
run: |
# Add git info
git config --global user.email "do_not_email@example.com"
git config --global user.name "gh_action"
# Render website
echo "Rendering qmd files ..."
echo "pwd: ${pwd}"
echo "PWD: ${PWD}"
docker run --rm -u $(id -u ${USER}):$(id -g ${USER}) -v ${pwd}/scripts:/scripts -v ${pwd}/src:/src -v ${pwd}/docs:/qmd --env TEXINPUTS="../src/latex:$TEXINPUTS" ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}
# - name: Install pgip dependencies
# run: |
# python -m ipykernel install --user --name pgip --display-name "Population Genomics in Practice (Python)"
# python -m pip install git+https://github.com/NBISweden/pgip-tools
# python -m pip install git+https://github.com/ksamuk/pixy.git
# - name: Install dotenv
# run: |
# R -e "install.packages('dotenv', repos=c(CRAN = 'https://cran.rstudio.com/'))"
# - name: Install TeXLive
# run: |
# sudo apt-get update
# sudo apt-get install texlive texlive-latex-extra
# - name: Install local pgip R package
# run: |
# R -e "library(devtools); devtools::install_local('src/R/pgip', upgrade=F)"
# - name: Setup Quarto
# uses: quarto-dev/quarto-actions/setup@v2
# with:
# version: 1.3.450
# - run: |
# quarto --version
# - name: Add miniconda path
# run: |
# echo "$(dirname $(which R))" >> $GITHUB_PATH
# quarto check
# - name: "Set environment variables"
# run: |
# echo "TEXINPUTS=$TEXINPUTS:$GITHUB_WORKSPACE/src/latex" >> $GITHUB_ENV
# - name: Install dvisvgm
# run: |
# sudo apt-get install dvisvgm
# - name: Render project without publishing
# uses: quarto-dev/quarto-actions/render@v2
# if: ${{ github.event_name == 'pull_request' }}
# with:
# path: docs
# - name: Publish to GitHub Pages
# uses: quarto-dev/quarto-actions/publish@v2
# if: ${{ github.ref_name == 'main' || github.ref_name == 'test-build' }}
# with:
# target: gh-pages
# path: docs
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Create archive branch
# if: startsWith(github.ref, 'refs/tags/v')
# run: |
# echo "Creating archive branch archive-${{ github.ref_name }}"
# if git show-ref --quiet "refs/heads/archive-${{ github.ref_name }}"; then
# echo "archive-${{ github.ref_name }}" branch exists
# else
# echo "Running git branch archive-${{ github.ref_name }}"
# git branch "archive-${{ github.ref_name }}"
# fi
# - name: Render tag and save rendered state in separate branch
# if: startsWith(github.ref, 'refs/tags/v')
# env:
# GITHUB_EMAIL: do_not_email@example.com
# GITHUB_USERNAME: gh_action
# TARGET: "archive-${{ github.ref_name }}"
# run: |
# # Add git info
# git config --global user.email "${{ env.GITHUB_EMAIL }}"
# git config --global user.name "${{ env.GITHUB_USERNAME }}"
# git clone --single-branch --branch ${{ env.TARGET }} "https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" tmprepo
# # - name: Render tag and save rendered state in separate branch
# # uses: quarto-dev/quarto-actions/publish@v2
# # if: startsWith(github.ref, 'refs/tags/v')
# # with:
# # target: "archive-${{ github.ref_name }}"
# # path: docs
# # env:
# # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Checkout archived course versions
# env:
# GITHUB_EMAIL: do_not_email@example.com
# GITHUB_USERNAME: gh_action
# TARGET: gh-pages
# run: |
# # Add git info
# git config --global user.email "${{ env.GITHUB_EMAIL }}"
# git config --global user.name "${{ env.GITHUB_USERNAME }}"
# git clone --single-branch --branch ${{ env.TARGET }} "https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" tmprepo
# cd tmprepo
# mkdir -p archive
# cd archive
# git branch -l
# ls -lh
# # Add archive index page
# cat .header.html > index.html
# # Loop tags that match v\d+
# for tag in $(git tag --list v[0-9][0-9][0-9][0-9]); do
# if [ -d $tag ]; then
# echo "Directory ${tag} already exsists. Removing"
# git rm -f $tag
# fi
# git clone --depth 1 --branch "archive-$tag" "https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" $tag
# git add -f $tag
# contents=$(git tag -n 100 $tag --format "%(contents)")
# echo "<section id=\"$tag\" class=\"level3\">" >> index.html
# echo "<h3 class=\"anchored\" data-anchor-id=\"$tag\">" >> index.html
# echo "<a href=\"$link\">$tag</a>" >> index.html
# echo "</h3>" >> index.html
# echo "<p>$contents</p>" >> index.html
# echo "</section>" >> index.html
# done
# cat .footer.html >> index.html
# git add -f index.html