Skip to content

Merge pull request #127 from jhudsl/repo-sync/OTTR_Template/default #503

Merge pull request #127 from jhudsl/repo-sync/OTTR_Template/default

Merge pull request #127 from jhudsl/repo-sync/OTTR_Template/default #503

# Code adapted from https://github.com/JetBrains/intellij-platform-plugin-template/blob/deb171483598ee8a5d7621154db880e87b4db4ef/.github/workflows/template-cleanup.yml
# by Candace Savonen for this repository.
name: Starting a new course
on:
push:
branches:
- main
workflow_dispatch:
jobs:
# Run cleaning process only if workflow is triggered by not being in the Leanpub template anymore
template-cleanup:
name: Template Cleanup
runs-on: ubuntu-latest
if: github.event.repository.name != 'OTTR_Quizzes'
steps:
# Check out current repository
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
##### Delete Template-specific files that aren't needed for new courses
# Cleanup Template-specific bits
- name: Cleanup
run: |
# Cleanup
rm -rf \
.github/workflows/send-updates.yml \
.github/workflows/test-send-updates.yml \
.github/sync.yml \
.github/test-sync.yml \
.github/workflows/starting-course.yml \
.github/ISSUE_TEMPLATE/issue_template.md \
.github/PULL_REQUEST_TEMPLATE/add_to_sync_template.md \
resources/chapt_screen_images/* \
resources/code_output \
resources/screenshots \
resources/course_screenshots \
resources/gs_slides \
resources/*.png \
resources/images/* \
manuscript/* \
quizzes/quiz_bad.md \
# Commit modified files
- name: Commit deleted files
id: commit_it
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "Template cleanup"
pushed_it=true
git push || pushed_it=false
echo ::set-output name=pushed_it::$pushed_it
# If main is already protected, then file a PR
- name: Create PR with deleted files
if: steps.commit_it.outputs.pushed_it == 'false'
uses: peter-evans/create-pull-request@v3
id: pr
with:
commit-message: Delete unnecessary files
signoff: false
branch: auto_copy_rendered_files
delete-branch: true
title: 'Automatic course set up'
body: |
### Description:
This PR was initiated by the github actions. It helps set up this repository to be ready to write your course.
It deletes some remnant files you don't need for your course but were used when this was a template.
labels: |
automated
reviewers: $GITHUB_ACTOR