Skip to content

Commit 40beda0

Browse files
committed
Merge branch 'diff-vs-deployed'
2 parents f23cc8a + 299d75a commit 40beda0

File tree

2 files changed

+121
-30
lines changed

2 files changed

+121
-30
lines changed

.github/workflows/publish.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,127 @@ jobs:
4141
- name: Build site in container
4242
run: docker-compose run docs rake build
4343

44+
changes:
45+
runs-on: ubuntu-latest
46+
if: github.ref != 'refs/heads/main'
47+
outputs:
48+
build-system: ${{ steps.filter.outputs.build-system }}
49+
steps:
50+
- name: Check if build system changed
51+
uses: dorny/paths-filter@v3
52+
id: filter
53+
with:
54+
filters: |
55+
build-system:
56+
- _config.yml
57+
- .github/**/*
58+
- Gemfile*
59+
- Rakefile
60+
61+
build-main:
62+
needs:
63+
- changes
64+
if: needs.changes.outputs.build-system == 'true'
65+
env:
66+
# ruby/setup-ruby@v1 does not offer a way to change the cached gems path.
67+
# See https://github.com/ruby/setup-ruby/issues/291
68+
GLOBAL_GEMS: 1
69+
runs-on: ubuntu-latest
70+
steps:
71+
- uses: actions/checkout@v4
72+
with:
73+
ref: main
74+
submodules: recursive
75+
76+
- name: Set up Ruby
77+
uses: ruby/setup-ruby@v1
78+
with:
79+
bundler-cache: true
80+
cache-version: 2
81+
82+
- name: Build
83+
run: rake build
84+
85+
- name: Upload build site
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: build-from-main
89+
path: _site
90+
91+
diff:
92+
runs-on: ubuntu-latest
93+
needs:
94+
- build-validate
95+
- build-main
96+
permissions:
97+
pull-requests: write
98+
steps:
99+
- name: Download artifact from this branch's build
100+
uses: actions/download-artifact@v4
101+
with:
102+
name: github-pages
103+
104+
- name: Unpack local build
105+
run: |
106+
mkdir local
107+
pushd local
108+
tar --extract --file ../artifact.tar
109+
popd
110+
mv artifact.tar local.tar
111+
112+
- name: Download artifact from main branch build
113+
uses: actions/download-artifact@v4
114+
with:
115+
name: build-from-main
116+
path: main
117+
118+
- name: Diff
119+
id: diff
120+
run: |
121+
set +e
122+
diff -ru main local > ./result.diff
123+
result=$?
124+
set -euo pipefail
125+
126+
delimiter="gha-delim-$RANDOM-$RANDOM-gha-delim"
127+
{
128+
echo "diff<<${delimiter}"
129+
cat ./result.diff
130+
echo "${delimiter}"
131+
} >> "$GITHUB_OUTPUT"
132+
133+
cat ./result.diff
134+
135+
if [[ $result -ne 0 ]]
136+
then
137+
echo has-changes=true >> "$GITHUB_OUTPUT"
138+
else
139+
echo has-changes=false >> "$GITHUB_OUTPUT"
140+
fi
141+
142+
- name: Build comment
143+
id: build-comment
144+
if: always()
145+
run: |
146+
{
147+
if [[ "${{ steps.diff.outputs.has-changes }}" = "true" ]]
148+
then
149+
echo "🔀 Build diff:"
150+
echo '```diff'
151+
cat ./result.diff
152+
echo '```'
153+
else
154+
echo "Build has no changes."
155+
fi
156+
} > ./comment.md
157+
158+
- name: Post diff to PR
159+
uses: thollander/actions-comment-pull-request@v2
160+
if: always()
161+
with:
162+
comment_tag: build-diff
163+
filePath: ./comment.md
164+
44165
deploy:
45166
name: Deploy to GitHub Pages
46167
runs-on: ubuntu-latest

feed.xml

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)