Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically delete the corresponding branch in the doaj-docs... #2437

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 50 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
on:
push:
branches:
- master
- develop
- feature/*

- master
- develop
- feature/*
delete:
branches:
- '*'

jobs:
gen_docs:
name: generate DOAJ documentation and functional tests and push to the docs repo
Expand Down Expand Up @@ -56,3 +59,46 @@ jobs:
git add .
git commit -m "GH Actions docs run for ${{ github.ref_name }}"
git push

delete_docs_folder:
name: Remove corresponding folder in DOAJ/doaj-docs when a branch is deleted
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout the doaj-docs repository
uses: actions/checkout@v4
with:
path: doaj-docs
repository: DOAJ/doaj-docs
token: ${{ secrets.STEVE_PAT_DOAJ_ACTIONS_DOCS }}
fetch-depth: 0

- name: Delete corresponding folder
env:
BRANCH_NAME: ${{ github.ref }}
run: |
FOLDER_PATH="${{ env.BRANCH_NAME#refs/heads/ }}"
BASE_FOLDER=$(dirname "$FOLDER_PATH")
TARGET_FOLDER=$(basename "$FOLDER_PATH")

# Check if base folder and target folder exist
if [ -d "$GITHUB_WORKSPACE/doaj-docs/$BASE_FOLDER" ]; then
cd $GITHUB_WORKSPACE/doaj-docs/$BASE_FOLDER

if [ -d "$TARGET_FOLDER" ]; then
rm -rf "$TARGET_FOLDER"
echo "Deleted folder $TARGET_FOLDER"
cd $GITHUB_WORKSPACE/doaj-docs
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "deleted: $TARGET_FOLDER"
git push origin master
else
echo "$FOLDER_PATH doesn't have a corresponding folder in doaj-docs"
fi
else
echo "$FOLDER_PATH doesn't have a corresponding folder in doaj-docs"
fi