-
Notifications
You must be signed in to change notification settings - Fork 233
94 lines (88 loc) · 2.94 KB
/
shadow-repo-update.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
name: Shadow Repo / Update
on:
create:
delete:
workflow_run:
workflows: Shadow Repo
types: [completed]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
create:
name: Create Branch
runs-on: ubuntu-latest
if: github.event.ref_type == 'branch' && github.event_name == 'create'
steps:
- name: Clone shadow repo
uses: actions/checkout@v4
with:
repository: ${{ vars.SHADOW_OWNER }}/${{ vars.SHADOW_REPO }}
token: ${{ secrets.SASS_SITE_TOKEN }}
ref: main
- name: Create branch on shadow repo
run: git push origin main:${{ github.event.ref }}
delete:
name: Delete Branch
runs-on: ubuntu-latest
if: github.event.ref_type == 'branch' && github.event_name == 'delete'
steps:
- name: Clone shadow repo
uses: actions/checkout@v4
with:
repository: ${{ vars.SHADOW_OWNER }}/${{ vars.SHADOW_REPO }}
token: ${{ secrets.SASS_SITE_TOKEN }}
ref: main
- name: Delete branch on shadow repo
run: git push origin --delete ${{ github.event.ref }}
push:
name: Push
runs-on: ubuntu-latest
if: github.event_name == 'workflow_run'
steps:
- name: Download built site
id: download_site
uses: dawidd6/action-download-artifact@v7
with:
name: site
run_id: ${{ github.event.workflow_run.id }}
if_no_artifact_found: ignore
- name: Clone shadow repo
uses: actions/checkout@v4
if: steps.download_site.outputs.found_artifact == 'true'
with:
repository: ${{ vars.SHADOW_OWNER }}/${{ vars.SHADOW_REPO }}
token: ${{ secrets.SASS_SITE_TOKEN }}
ref: ${{ github.ref_name }}
path: shadow-repo
- name: Update shadow repo files
if: steps.download_site.outputs.found_artifact == 'true'
run: |
rm -rf shadow_repo/*
tar xf site.tar
cp -rT _site shadow_repo
- uses: EndBug/add-and-commit@v9
if: steps.download_site.outputs.found_artifact == 'true'
with:
cwd: shadow-repo
author_name: Sass Bot
author_email: [email protected]
message: Update from https://github.com/${{ github.repository }}/commit/${{ github.sha }}
commit: --allow-empty
diff-link:
name: Comment
runs-on: ubuntu-latest
if: github.event_name == 'workflow_run'
steps:
- name: Download comment text
id: download_comment
uses: dawidd6/action-download-artifact@v7
with:
name: comment
run_id: ${{ github.event.workflow_run.id }}
if_no_artifact_found: ignore
- uses: peter-evans/create-or-update-comment@v4
if: steps.download_comment.outputs.found_artifact == 'true'
with:
issue-number: ${{ github.event.number }}
body-path: comment.txt