-
Notifications
You must be signed in to change notification settings - Fork 32
166 lines (163 loc) · 6.37 KB
/
workflow.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: abtech.org
on:
push:
branches:
- 'main'
- 'dev'
- '!gh-pages'
- '!gh-pages-dev'
tags:
- '*'
pull_request:
branches:
- 'main'
- 'dev'
jobs:
# build-docker:
# runs-on: ubuntu-latest
# outputs:
# IMAGE_ID: ${{ steps.push-image.outputs.IMAGE_ID }}
# VERSION: ${{ steps.push-image.outputs.VERSION }}
# VERSIONSHA: ${{ steps.push-image.outputs.VERSIONSHA }}
# CIVERSION: ${{ steps.push-image.outputs.CIVERSION }}
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: 🏗 Set up build cache
# id: cache
# uses: actions/cache@v2
# with:
# path: /tmp/.docker-cache
# key: ${{ runner.os }}-buildDocker-${{ env.cache-name }}-${{ github.ref }}-${{ github.sha }}-${{ hashFiles('**/Dockerfile') }}
# restore-keys: |
# ${{ runner.os }}-buildDocker-${{ env.cache-name }}-${{ github.ref }}-
# ${{ runner.os }}-buildDocker-${{ env.cache-name }}-
# - name: Build image
# run: docker build . --file Dockerfile --tag ${{ github.event.repository.name }} --label "runnumber=${{ github.run_id }}"
# - name: Log into registry
# run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
# - name: Push image
# id: push-image
# if: github.event_name != 'pull_request'
# run: |
# IMAGE_ID=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
# # Change all uppercase to lowercase
# IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# # Strip git ref prefix from version
# VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# # Strip "v" prefix from tag name
# [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# # Use sha too
# VERSIONSHA="${{ github.sha }}"
# echo IMAGE_ID=$IMAGE_ID
# echo VERSION=$VERSION
# echo VERSIONSHA=$VERSIONSHA
# [[ "${{ github.event_name }}" != "pull_request" ]] && CIVERSION=$VERSIONSHA
# [[ "${{ github.event_name }}" == "pull_request" ]] && CIVERSION="latest"
# echo "::set-output name=IMAGE_ID::$IMAGE_ID"
# echo "::set-output name=VERSION::$VERSION"
# echo "::set-output name=VERSIONSHA::$VERSIONSHA"
# echo "::set-output name=CIVERSION::$CIVERSION"
# # Use Docker `latest` tag convention
# if [[ "${{ github.event_name }}" != "pull_request" ]]; then
# [ "$VERSION" == "main" ] && docker tag ${{ github.event.repository.name }} $IMAGE_ID:latest
# docker tag ${{ github.event.repository.name }} $IMAGE_ID:$VERSION
# docker tag ${{ github.event.repository.name }} $IMAGE_ID:$VERSIONSHA
# docker push $IMAGE_ID --all-tags
# fi
build:
# needs: build-docker
runs-on: ubuntu-latest
container:
# image: ${{ needs.build-docker.outputs.IMAGE_ID }}:${{ needs.build-docker.outputs.CIVERSION }}
image: "ghcr.io/abtech/abtech.org:fefc2b479d4c22d6b3e00b1b359a5be2780d7fbe"
steps:
- name: Checkout latest
uses: actions/checkout@v2
# - name: Cache Ruby dependencies
# uses: actions/cache@v2
# env:
# cache-name: cache-ruby-gems
# with:
# path: vendor/bundle
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.ref }}-${{ hashFiles('**/Gemfile.lock', '**/Gemfile', '**/Dockerfile') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.ref }}-
# ${{ runner.os }}-build-${{ env.cache-name }}-
# - name: Cache NodeJS dependencies
# uses: actions/cache@v2
# env:
# cache-name: cache-node-modules
# with:
# path: ~/.npm
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.ref }}-${{ hashFiles('**/package-lock.json', '**/package.json', '**/Dockerfile') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.ref }}-
# ${{ runner.os }}-build-${{ env.cache-name }}-
- name: Install all dependencies # This includes bundler with NPM preinstall script
run: npm install --unsafe-perm
- name: Build Jekyll
run: npm run-script build-prod
- name: Archive files
run: tar -cvf _site.tar -C _site .
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: "_site.tar"
path: _site.tar
publish:
needs: build
runs-on: ubuntu-latest
if: |
github.ref == 'refs/heads/main' &&
github.event_name != 'pull_request'
steps:
- name: Checkout gh-pages branch of repo
uses: actions/checkout@v2
with:
ref: "gh-pages"
- name: Clear branch of previous build
run: |
git rm -rf . --ignore-unmatch
git clean -fxd
- name: Download built artifact
uses: actions/download-artifact@v2
with:
name: "_site.tar"
- name: 'Unarchive files & remove archive'
run: tar -xvf _site.tar && rm _site.tar
- name: Commit and push new artifact
run: |
git config user.name github-actions
git config user.email [email protected]
git add . --all
git commit --allow-empty -m "abtech.org publish $GITHUB_SHA"
git push
publish-dev:
needs: build
runs-on: ubuntu-latest
if: |
github.ref == 'refs/heads/dev' &&
github.event_name != 'pull_request'
steps:
- name: Checkout gh-pages-dev branch of repo
uses: actions/checkout@v2
with:
ref: "gh-pages-dev"
- name: Clear branch of previous build
run: |
git rm -rf . --ignore-unmatch
git clean -fxd
- name: Download built artifact
uses: actions/download-artifact@v2
with:
name: "_site.tar"
- name: 'Unarchive files & remove archive'
run: tar -xvf _site.tar && rm _site.tar
- name: Commit and push new artifact
run: |
git config user.name github-actions
git config user.email [email protected]
git add . --all
git commit --allow-empty -m "abtech.org publish $GITHUB_SHA"
git push