-
Notifications
You must be signed in to change notification settings - Fork 3
112 lines (96 loc) · 3.63 KB
/
biocbook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: biocbook
on:
push:
branches:
- devel
- RELEASE_**
jobs:
build-push:
runs-on: ubuntu-latest
name: build-book (${{ github.ref_name }})
permissions:
contents: write
packages: write
steps:
- name: 🧾 Checkout repository
uses: actions/checkout@v3
- name: ⏳ Collect Workflow Telemetry
uses: runforesight/workflow-telemetry-action@v1
- name: 🐳 Set up QEMU
uses: docker/setup-qemu-action@v2
- name: 🐳 Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: 📝 Get book info
id: info
env:
OWNER: ${{ github.repository_owner }}
run: |
Pkgname=$(grep -m1 -E '^Package: +' DESCRIPTION | sed -E 's/.*: +//')
echo Pkgname=${Pkgname} >> "${GITHUB_ENV}"
pkgname=${Pkgname,,}
echo pkgname=${pkgname} >> "${GITHUB_ENV}"
owner=${OWNER,,}
echo owner=${owner} >> "${GITHUB_ENV}"
echo pkgversion=$(grep -m1 -E '^Version: +' DESCRIPTION | sed -E 's/.*: +//') >> "${GITHUB_ENV}"
- name: 🔐 Log in to the Github Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ env.owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🏷 Get metadata for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ env.owner }}/${{ env.pkgname }}
tags: |
${{ github.ref_name }}
${{ env.pkgversion }}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'devel') }}
- name: 📦 Install, build and check package in local Docker image
id: docker
uses: docker/build-push-action@v4
with:
context: .
load: true
tags: ${{ steps.meta.outputs.tags }}
build-args: |
BIOC_VERSION=${{ github.ref_name }}
- name: 🚀 Push local Docker image to ghcr.io
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
build-args: |
BIOC_VERSION=${{ github.ref_name }}
- name: 📚 Recover pkg artifacts generated during build in local Docker container (pkg bundle and book)
env:
IMG: ${{ steps.docker.outputs.ImageID }}
run: |
SHA=$(docker container create ${{ env.IMG }})
docker container cp ${SHA}:/${{ env.Pkgname }}_${{ env.pkgversion }}.tar.gz .
tar --extract --gzip --file ${{ env.Pkgname }}_${{ env.pkgversion }}.tar.gz
echo bundle_path=${{ env.Pkgname }}_${{ env.pkgversion }}.tar.gz >> "${GITHUB_ENV}"
echo book_path=${{ env.Pkgname }}/inst/doc/book/ >> "${GITHUB_ENV}"
ls -l $(${{ env.Pkgname }}/inst/doc/book/)
- name: 🏷 Get gh-branch directory to deploy to
run: |
echo target_folder=$(echo ${{ github.ref_name }} | sed 's,RELEASE_,,' | tr '_' '.') >> "${GITHUB_ENV}"
- name: 🚀 Deploy book to Github Pages on versioned branch
uses: JamesIves/[email protected]
with:
folder: ${{ env.book_path }}/
target-folder: docs/${{ env.target_folder }}/
branch: gh-pages
clean: false
- name: 💾 Upload package bundle artifact
uses: actions/upload-artifact@v3
with:
name: bundle
path: ${{ env.bundle_path }}
- name: 💾 Upload book artifact
uses: actions/upload-artifact@v3
with:
name: book
path: ${{ env.book_path }}