-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (147 loc) · 4.6 KB
/
cicd.yaml
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
name: CICD
on:
push:
env:
# shinytest2 on GHA is very slow
SHINYTEST2_LOAD_TIMEOUT: 16000
SHINYTEST2_TIMEOUT: 8000
concurrency:
group: ${{ github.ref }}
# main should run through entire queue of commits for debugging
cancel-in-progress: ${{ github.ref_name != 'main' }}
jobs:
build-and-push-images:
name: "Build and Push Images"
# auth-ing to GHCR with same same user may cause problems
# run_id is a backup if token is undefined
concurrency: ${{ github.token || github.run_id }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: "linux/amd64, linux/arm64"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: false
- name: Extract Metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
# image names and tags are actually defined in the bakefile
# TODO this should done by metadata-action,
# but is currently unsupported
images: "i-am-ignored"
- name: "Bake Images"
run: |
make bake \
bake_args="--file ${{ steps.meta.outputs.bake-file }} from-r-ver" \
tag_from_git_sha="${{ github.sha }}" \
git_ref_name="${{ github.ref_name }}"
- name: "Smoke Test Builder Image"
run: |
make smoke-test-builder git_ref_name="${{ github.ref_name }}"
- name: "Push Images"
run: |
make bake \
bake_args="--file ${{ steps.meta.outputs.bake-file }} from-r-ver" \
tag_from_git_sha="${{ github.sha }}" \
git_ref_name="${{ github.ref_name }}" \
can_push=true
make-all-in-docker:
name: "Test, Check, Lint and Document Package"
needs: build-and-push-images
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}/builder:${{ github.sha }}
strategy:
fail-fast: false
matrix:
make_target: [
test-installed,
check,
pkgdown,
rlint,
check-clean-namespace
]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Appease Git
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Init Git
if: ${{ matrix.make_target == 'check-clean-namespace' }}
run: |
git init
- name: Make ${{ matrix.make_target }}
run: |
apt-get update
make ${{ matrix.make_target }}
- name: Upload Pkgdown Website as an Artifact
if: ${{ matrix.make_target == 'pkgdown' }}
uses: actions/upload-artifact@v4
with:
name: "pkgdown website"
path: "docs/"
lint-all:
name: Lint Code Base (Except R)
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of
# changed files within `super-linter`
fetch-depth: 0
- name: Lint Code Base
uses: github/super-linter@v6
env:
FILTER_REGEX_EXCLUDE: ^\/(.*?)(tests\/)(testthat\/)(_snaps\/)(.*?).md$
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: .
# for docs, see workflows repo
IGNORE_GITIGNORED_FILES: true
IGNORE_GENERATED_FILES: true
VALIDATE_NATURAL_LANGUAGE: false
VALIDATE_R: false
VALIDATE_TERRAGRUNT: false
VALIDATE_CHECKOV: false
publish:
name: "Publish pkgdown Website to Cloudflare"
permissions:
contents: read
deployments: write
needs: [
make-all-in-docker,
lint-all
]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: "pkgdown website"
path: docs/
- name: Display structure of downloaded files
run: ls -R
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN_PAGES }}
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID_HELDEN18DE }}
projectName: crow
directory: docs/
gitHubToken: ${{ secrets.GITHUB_TOKEN }}