sass-site/.github/workflows/shadow-repo-update.yml

72 lines
2.1 KiB
YAML
Raw Normal View History

name: Shadow Repo / Update
2023-01-31 23:33:07 +01:00
on:
create:
delete:
workflow_run:
workflows: Shadow Repo
types: [completed]
2023-01-31 23:33:07 +01:00
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
create:
name: Create Branch
2023-01-31 23:33:07 +01:00
runs-on: ubuntu-latest
if: github.event.ref_type == 'branch' && github.event_name == 'create'
2023-01-31 23:33:07 +01:00
steps:
- name: Clone shadow repo
uses: actions/checkout@v3
with:
repository: ${{ vars.SHADOW_OWNER }}/${{ vars.SHADOW_REPO }}
token: ${{ secrets.SASS_SITE_TOKEN }}
2023-01-31 23:33:07 +01:00
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@v3
with:
repository: ${{ vars.SHADOW_OWNER }}/${{ vars.SHADOW_REPO }}
token: ${{ secrets.SASS_SITE_TOKEN }}
ref: main
2023-01-31 23:33:07 +01:00
- name: Delete branch on shadow repo
run: git push origin --delete ${{ github.event.ref }}
push:
name: Push
2023-01-31 23:33:07 +01:00
runs-on: ubuntu-latest
if: github.event_name == 'workflow_run'
2023-01-31 23:33:07 +01:00
steps:
- name: Clone shadow repo
uses: actions/checkout@v3
with:
2023-01-31 23:45:08 +01:00
repository: ${{ vars.SHADOW_OWNER }}/${{ vars.SHADOW_REPO }}
token: ${{ secrets.SASS_SITE_TOKEN }}
2023-01-31 23:33:07 +01:00
ref: ${{ github.ref_name }}
path: shadow-repo
- name: Download built site
uses: dawidd6/action-download-artifact@v2.27.0
with:
name: site
run_id: ${{ github.event.workflow_run.id }}
2023-06-22 22:39:00 +02:00
- name: Update shadow repo files
2023-01-31 23:33:07 +01:00
run: |
rm -rf shadow_repo/*
tar xf site.tar
cp -rT _site shadow_repo
2023-06-22 22:34:15 +02:00
- uses: EndBug/add-and-commit@v9
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