Skip to content

Shadow Repo / Update #1808

Shadow Repo / Update

Shadow Repo / Update #1808

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@v6
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: sass.bot.beep.boop@gmail.com
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@v6
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