Skip to content

Commit 28cc789

Browse files
authored
Merge pull request #288 from onflow/hannah/call-docs-refresh-with-diff
Add github actions for getting diff & calling refresh > @codingone21 Thank you for automating this, but it got me wondering, could we extract this whole thing in our own Github action that could be then referenced in all the CDs? cc @10thfloor I think that is possible! We already refactored the 'refresh' workflow into a singular repository (in /flow). We can take it a step further to refactor more common code into a single workflow, and call this in fewer lines of code.
2 parents de1578d + d5c2571 commit 28cc789

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This workflow is stored and called from each repository that contains documentation files
2+
name: call-refresh-doc
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
compare:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Get changed files
15+
id: changed-files
16+
uses: tj-actions/changed-files@v19
17+
with:
18+
files: |
19+
docs/**/*.md
20+
docs/**/*.mdx
21+
22+
# --- Log all diff info ---
23+
- name: Log the files commit SHA if any md/mdx files have diffs
24+
continue-on-error: true
25+
if: steps.changed-files.outputs.any_modified == 'true'
26+
run: |
27+
for file in ${{ steps.changed-files.outputs.all_modified_files }}; do
28+
echo "$file was modified" with the commit ${{ github.sha }}
29+
done
30+
for file in ${{ steps.changed-files.outputs.added_files }}; do
31+
echo "$file was added"
32+
done
33+
for file in ${{ steps.changed-files.outputs.deleted_files }}; do
34+
echo "$file was deleted"
35+
done
36+
for file in ${{ steps.changed-files.outputs.all_modified_files }}; do
37+
echo "$file was modified"
38+
done
39+
outputs:
40+
all_modified_files: ${{ steps.changed-files.outputs.all_modified_files }}
41+
any_modified: ${{ steps.changed-files.outputs.any_modified }}
42+
43+
# --- If modified, call refresh ---
44+
call-refresh-workflow-passing-data:
45+
runs-on: ubuntu-latest
46+
needs: compare
47+
if: ${{ needs.compare.outputs.all_modified_files != 0 }}
48+
uses: onflow/flow/.github/workflows/refresh-doc.yml@master
49+
with:
50+
contentPaths: ${{ needs.compare.outputs.all_modified_files }}
51+
repository: ${{ github.event.repository.name }}
52+
commitSha: ${{ github.sha }}

0 commit comments

Comments
 (0)