Skip to content

Commit 50bb7d7

Browse files
authored
Merge pull request #281 from cmu-delphi/sgratzl/advancedworkflows
advanced github action workflows
2 parents 8ba2a7e + 05bdcfc commit 50bb7d7

File tree

9 files changed

+372
-2798
lines changed

9 files changed

+372
-2798
lines changed

.github/release-drafter.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name-template: "v$RESOLVED_VERSION"
2+
tag-template: "v$RESOLVED_VERSION"
3+
categories:
4+
- title: "📚 Content Changes"
5+
labels:
6+
- "blog"
7+
- "documentation"
8+
- title: "🚀 Features"
9+
labels:
10+
- "enhancement"
11+
- "feature"
12+
- title: "🐛 Bugs Fixes"
13+
labels:
14+
- "bug"
15+
- title: "🧰 Development"
16+
labels:
17+
- "chore"
18+
change-template: "- #$NUMBER $TITLE"
19+
change-title-escapes: '\<*_&`#@'
20+
template: |
21+
$CHANGES
22+
23+
Thanks to $CONTRIBUTORS

.github/workflows/blog.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: blog
2+
3+
on:
4+
push:
5+
paths: # run only when an Rmd file changes
6+
- "**.Rmd"
7+
- "environment.yml"
8+
- ".github/workflows/ci.yaml"
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
# submodules: true # Fetch Hugo themes (true OR recursive)
17+
fetch-depth: 3
18+
- name: Cache Conda
19+
uses: actions/cache@v1
20+
with:
21+
path: ~/conda_pkgs_dir
22+
key: ${{ runner.os }}-conda6-${{ hashFiles('environment.yml') }}
23+
restore-keys: |
24+
${{ runner.os }}-conda6-
25+
- uses: conda-incubator/setup-miniconda@v2
26+
with:
27+
python-version: 3.9
28+
mamba-version: "*"
29+
channels: conda-forge,defaults
30+
channel-priority: true
31+
activate-environment: www-main
32+
environment-file: environment.yml
33+
auto-activate-base: false
34+
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
35+
# - name: Conda info
36+
# shell: bash -l {0}
37+
# run: |
38+
# conda info
39+
# conda list
40+
- name: Install R dependencies
41+
shell: bash -l {0}
42+
run: |
43+
Rscript ./dependencies.R
44+
- name: Restore Blogdown Cache
45+
uses: actions/cache@v2
46+
with:
47+
path: |
48+
./blogdown
49+
key: ${{ runner.os }}-blogdown2-${{ hashFiles('environment.yml') }}-${{ hashFiles('content/blog/**.Rmd') }}
50+
restore-keys: |
51+
${{ runner.os }}-blogdown2-${{ hashFiles('environment.yml') }}-
52+
${{ runner.os }}-blogdown2-
53+
- name: Build site
54+
shell: bash -l {0}
55+
run: |
56+
npm run build:blog
57+
58+
- uses: actions/upload-artifact@v2
59+
with:
60+
name: blog
61+
path: |
62+
./content/blog
63+
./static/blog
64+
65+
- uses: actions/setup-node@v1
66+
with:
67+
node-version: "12"
68+
- uses: actions/cache@v2
69+
with:
70+
path: ~/.npm
71+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
72+
restore-keys: |
73+
${{ runner.os }}-node-
74+
- run: npm ci
75+
- name: Lint
76+
run: npm run lint
77+
- name: Build
78+
run: npm run build
79+
80+
- uses: actions/upload-artifact@v2
81+
with:
82+
name: website
83+
path: ./public

.github/workflows/ci.yaml

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,25 @@
1-
on:
2-
push:
3-
paths: # run only when an Rmd file changes
4-
- "**.Rmd"
5-
- "environment.yml"
6-
- ".github/workflows/ci.yaml"
7-
81
name: ci
92

3+
on: push
4+
105
jobs:
116
build:
127
runs-on: ubuntu-latest
138
steps:
149
- uses: actions/checkout@v2
1510
with:
1611
# submodules: true # Fetch Hugo themes (true OR recursive)
17-
fetch-depth: 3
18-
- name: Cache Conda
19-
uses: actions/cache@v1
20-
with:
21-
path: ~/conda_pkgs_dir
22-
key: ${{ runner.os }}-conda6-${{ hashFiles('environment.yml') }}
23-
restore-keys: |
24-
${{ runner.os }}-conda6-
25-
- uses: conda-incubator/setup-miniconda@v2
26-
with:
27-
python-version: 3.9
28-
mamba-version: "*"
29-
channels: conda-forge,defaults
30-
channel-priority: true
31-
activate-environment: www-main
32-
environment-file: environment.yml
33-
auto-activate-base: false
34-
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
35-
# - name: Conda info
36-
# shell: bash -l {0}
37-
# run: |
38-
# conda info
39-
# conda list
40-
- name: Install R dependencies
41-
shell: bash -l {0}
42-
run: |
43-
Rscript ./dependencies.R
44-
- name: Restore Blogdown Cache
45-
uses: actions/cache@v2
46-
with:
47-
path: |
48-
./blogdown
49-
key: ${{ runner.os }}-blogdown2-${{ hashFiles('environment.yml') }}-${{ hashFiles('content/blog/**.Rmd') }}
50-
restore-keys: |
51-
${{ runner.os }}-blogdown2-${{ hashFiles('environment.yml') }}-
52-
${{ runner.os }}-blogdown2-
53-
- name: Build site
54-
shell: bash -l {0}
55-
run: |
56-
npm run build:blog
57-
58-
- uses: actions/upload-artifact@v2
59-
with:
60-
name: blog
61-
path: |
62-
./content/blog
63-
./static/blog
12+
fetch-depth: 3 # Fetch all history for .GitInfo and .Lastmod
6413

65-
- uses: actions/setup-node@v1
14+
- uses: actions/setup-node@v2.1.5
6615
with:
67-
node-version: "12"
16+
node-version: "14"
6817
- uses: actions/cache@v2
6918
with:
7019
path: ~/.npm
71-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
20+
key: ${{ runner.os }}-node3-${{ hashFiles('**/package-lock.json') }}
7221
restore-keys: |
73-
${{ runner.os }}-node-
22+
${{ runner.os }}-node3-
7423
- run: npm ci
7524
- name: Lint
7625
run: npm run lint
@@ -81,3 +30,54 @@ jobs:
8130
with:
8231
name: website
8332
path: ./public
33+
34+
image:
35+
needs: build
36+
# only on tags and dev branch
37+
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/dev'
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Check out code
41+
uses: actions/checkout@v2
42+
- name: Login to GitHub Container Registry
43+
uses: docker/login-action@v1
44+
with:
45+
registry: ghcr.io
46+
username: cmu-delphi-deploy-machine
47+
password: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_PAT }}
48+
- name: Build Image
49+
env:
50+
DEVOPS_DOCKER_FILE: ./devops/Dockerfile
51+
run: |
52+
docker build -t repo --file ${DEVOPS_DOCKER_FILE} .
53+
- name: Resolve Tag
54+
id: tagname
55+
run: |
56+
baseRef="${GITHUB_REF#*/}"
57+
imageTag="${baseRef#*/}"
58+
echo -n "::set-output name=tag::$imageTag"
59+
echo -n "::set-output name=repo::ghcr.io/${{ github.repository }}"
60+
- name: Push Image Tag
61+
run: |
62+
docker tag repo ${{ steps.tagname.outputs.repo }}:${{ steps.tagname.outputs.tag }}
63+
docker push ${{ steps.tagname.outputs.repo }}:${{ steps.tagname.outputs.tag }}
64+
- name: Trigger Webhook
65+
run: |
66+
# trigger a webhook update
67+
curl -H "Authorization: Bearer ${{ secrets.DELPHI_DEPLOY_WEBHOOK_TOKEN }}" \
68+
-X POST ${{ secrets.DELPHI_DEPLOY_WEBHOOK_URL }} \
69+
-H "Content-Type: application/x-www-form-urlencoded" \
70+
-d "repository=${{ steps.tagname.outputs.repo }}&tag=${{ steps.tagname.outputs.tag }}"
71+
- name: Push Latest Tag
72+
if: startsWith(github.ref, 'refs/tags/v')
73+
run: |
74+
docker tag repo ${{ steps.tagname.outputs.repo }}:latest
75+
docker push ${{ steps.tagname.outputs.repo }}:latest
76+
- name: Trigger Latest Webhook
77+
if: startsWith(github.ref, 'refs/tags/v')
78+
run: |
79+
# trigger a webhook update
80+
curl -H "Authorization: Bearer ${{ secrets.DELPHI_DEPLOY_WEBHOOK_TOKEN }}" \
81+
-X POST ${{ secrets.DELPHI_DEPLOY_WEBHOOK_URL }} \
82+
-H "Content-Type: application/x-www-form-urlencoded" \
83+
-d "repository=${{ steps.tagname.outputs.repo }}&tag=latest"

.github/workflows/ci_fast.yaml

Lines changed: 0 additions & 70 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Create Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
versionName:
6+
description: "Semantic Version Number (i.e., 5.5.0 or patch, minor, major, prepatch, preminor, premajor, prerelease)"
7+
required: true
8+
default: patch
9+
jobs:
10+
create_release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out code
14+
uses: actions/checkout@v2
15+
with:
16+
ref: main
17+
ssh-key: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_SSH }}
18+
- name: Reset main branch
19+
run: |
20+
git fetch origin dev:dev
21+
git reset --hard dev
22+
- name: Change version number
23+
id: version
24+
run: |
25+
echo -n "::set-output name=next_tag::"
26+
npm version --no-git-tag-version ${{ github.event.inputs.versionName }}
27+
- name: Create pull request into main
28+
uses: peter-evans/create-pull-request@v3
29+
with:
30+
branch: release/${{ steps.version.outputs.next_tag }}
31+
commit-message: "chore: release ${{ steps.version.outputs.next_tag }}"
32+
base: main
33+
title: Release ${{ steps.version.outputs.next_tag }}
34+
labels: chore
35+
reviewers: krivard,sgratzl
36+
assignees: sgratzl
37+
body: |
38+
Releasing ${{ steps.version.outputs.next_tag }}.

0 commit comments

Comments
 (0)