-
Notifications
You must be signed in to change notification settings - Fork 108
42 lines (38 loc) · 1.43 KB
/
pr_workflow.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
# This workflow will build a middleman project with bundle
name: Testing For PRs
on: [ pull_request ]
env:
RUBYOPT: -W0 # needed to not print the warnings - makes the logs too big
RUN_EXTERNAL_CHECKS: true
jobs:
build_and_push_to_preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true # would run bundle install
- name: Set up user in git config
env:
USER: "${{ secrets.USER_TO_WRITE }}"
run: |
git config --global user.name "${USER}"
git config --global user.email "${USER}@github.com"
- name: Run the build
run: bundle exec rake build --verbose
- name: Build failed
if: ${{ failure() }}
run: bundle exec middleman build --verbose
- name: Push to preview
run: |
export PR_NO=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
git clone --depth=1 --branch=gh-pages "https://${USER}:${TOKEN}@github.com/gocd/pr-review.gocd.org" website
rm -rf website/pr-${PR_NO}
mv build website/pr-${PR_NO}
cd website && git config core.filemode false && git add -A .
git commit -m "Update website to ${PR_NO}" && git push
env:
USER: "${{ secrets.USER_TO_WRITE }}"
TOKEN: "${{ secrets.USER_TO_WRITE_ACCESS_TOKEN }}"