-
Notifications
You must be signed in to change notification settings - Fork 5
138 lines (122 loc) · 5.18 KB
/
build_and_publish.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
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
name: Gatsby Publish
on:
push:
branches:
[ main ]
pull_request:
types: [ opened, synchronize, reopened ]
schedule: ## Do a run three times daily, to refresh website content
- cron: '25 22,04,12 * * *'
workflow_dispatch:
defaults:
run:
shell: bash
concurrency:
group: uses-github-api # do not allow any concurrency or the different builds will fight for the github rate limit and all take far longer
jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: "npm" # this only caches global dependencies
- run: npm ci --prefer-offline
- run: npm run test
env:
CI: true
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get current date
id: date
run: |
echo "month=$(date +'%Y-%m')" >> "$GITHUB_OUTPUT"
echo "day=$(date +'%d')" >> "$GITHUB_OUTPUT"
- name: Restoring cached GitHub API results
uses: actions/cache@v4
with:
path: |
.cache-github-api
key: gatsby-build-github-queries-${{ steps.date.outputs.month }}-${{ steps.date.outputs.day }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: | # If there are multiple partial matches for a restore key, the action returns the most recently created cache.
gatsby-build-github-queries-${{ steps.date.outputs.month }}-${{ steps.date.outputs.day }}
gatsby-build-github-queries-
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: "npm" # this only caches global dependencies
- run: npm ci --prefer-offline
- run: npm run build -- ${{ github.ref_name == 'main' && '--prefix-paths' || '' }}
env:
NODE_ENV: production
GATSBY_ACTIVE_ENV: production
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TABLEAU_PERSONAL_ACCESS_TOKEN: ${{ secrets.TABLEAU_PERSONAL_ACCESS_TOKEN }}
TABLEAU_SITE: ${{ secrets.TABLEAU_SITE }}
SEGMENT_KEY: ${{ secrets.SEGMENT_KEY }}
- name: Caching GitHub API results
uses: actions/cache/save@v4 # save the cache even if the integration tests fail
with:
path: |
.cache-github-api
key: gatsby-build-github-queries-${{ steps.date.outputs.month }}-${{ steps.date.outputs.day }}-${{ github.run_id }}-${{ github.run_attempt }}
# run eslint on all files if eslintrc changes
- name: Run eslint on changed files
uses: sibiraj-s/action-eslint@v3
with:
all-files: ${{ steps.filter.outputs.eslintrc == 'true' }}
- run: npm run test:int
env:
CI: true
PATH_PREFIX: "${{ github.ref_name == 'main' && 'extensions' || '' }}"
PATH_PREFIX_FLAG: "${{ github.ref_name == 'main' && '--prefix-paths' || '' }}"
- name: Store PR id
if: "github.event_name == 'pull_request'"
run: echo ${{ github.event.number }} > ./public/pr-id.txt
- name: Publishing directory for site deployment
uses: actions/upload-artifact@v4
with:
name: site
path: ./public
retention-days: 3
deploy:
# Only try and deploy on merged code
if: "github.repository == 'quarkusio/extensions' && github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')"
needs: [ unit-test, build ]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4 # not needed for the code, but needed for the git config
- name: Download Built site
uses: actions/download-artifact@v4
with:
name: site
path: site
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: site # The folder the action should deploy.
branch: pages
raise-defects:
# Only try and raise defects on the main builds
if: "github.repository == 'quarkusio/extensions' && github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')"
# This doesn't actually need to run after the deploy, but we want it to wait as long as possible after the main build to give the github rate limit time to recover
needs: [ deploy ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4 # not needed for the code, but needed for the git config
- name: Download Built site
uses: actions/download-artifact@v4
with:
name: site
path: site
- name: Raise defects if needed
uses: jbangdev/[email protected]
if: "github.repository == 'quarkusio/extensions' && github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')"
with:
script: site-validation/bad-image-issue.java
scriptargs: token=${{ secrets.GITHUB_TOKEN }} issueRepo=${{ github.repository }} runId=${{ github.run_id }} siteUrl=https://quarkus.io/extensions