Skip to content

Commit

Permalink
new strqtegy for close PR
Browse files Browse the repository at this point in the history
  • Loading branch information
skoudoro committed Sep 21, 2023
1 parent a80800f commit 27e38df
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 31 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/preview-html.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
workflow_run:
workflows: ["Github Pages"]
types: [completed]
pull_request_target:
types: [closed]

jobs:
get-pr-number:
Expand Down Expand Up @@ -86,32 +84,3 @@ jobs:
number: ${{ needs.get-pr-number.outputs.output1 }}
id: deploy-preview
message: "A preview of ${{ github.event.workflow_run.head_commit.message }} is uploaded and can be seen here:\n\n ✨ ${{ env.BASE_URL }}/${{ env.PR_PATH }} ✨\n\nChanges may take a few minutes to propagate. The source is here: https://github.com/dipy/preview-html/tree/main/${{ env.PR_PATH }}/"
on-closed:
runs-on: ubuntu-latest
if: ${{ github.event.action == 'closed' }}
env:
PR_PATH: dipy.org/pull/${{github.event.number}}
steps:
- name: make empty dir
run: mkdir public

- name: delete folder
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_TOKEN }}
publish_dir: ./public
publish_branch: main
destination_dir: ${{ env.PR_PATH }}
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: ${{ github.event.head_commit.message }}

- name: Update PR Comment
uses: hasura/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
number: ${{ github.event.number }}
id: deploy-preview
message: "🪓 PR closed, deleted preview at https://github.com/dipy/preview-html/tree/main/${{ env.PR_PATH }}/"

36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ on:
branches:
- master
pull_request:
types: [opened, synchronize, edited, reopened]
branches:
- master
pull_request_target:
types: [closed]
branches:
- master
schedule:
- cron: '0 0 * * 1'

jobs:
deploy:
if: ${{ github.event.action != 'closed' }}
runs-on: ubuntu-latest
env:
PR_PATH: dipy.org/pull/${{github.event.number}}
Expand All @@ -23,12 +29,14 @@ jobs:
STATUS: ${{github.event.pull_request.head.repo.full_name != github.repository}}
steps:
- name: Save the PR number in an artifact
if: ${{ github.event == 'pull_request' }}
shell: bash
env:
PULL_REQUEST_NUMBER: ${{ github.event.number }}
run: echo $PULL_REQUEST_NUMBER > pull_request_number.txt

- name: Upload the PULL REQUEST number
if: ${{ github.event == 'pull_request' }}
uses: actions/upload-artifact@v2
with:
name: pull_request_number
Expand Down Expand Up @@ -67,3 +75,31 @@ jobs:
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: ${{ github.event.head_commit.message }}
# cname: ${{ env.DOMAIN # TODO: set this if you're using a custom domain.
on-closed:
runs-on: ubuntu-latest
if: ${{ github.event.action == 'closed' }}
env:
PR_PATH: dipy.org/pull/${{github.event.number}}
steps:
- name: make empty dir
run: mkdir public

- name: delete folder
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_TOKEN }}
publish_dir: ./public
publish_branch: main
destination_dir: ${{ env.PR_PATH }}
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: ${{ github.event.head_commit.message }}

- name: Update PR Comment
uses: hasura/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
number: ${{ github.event.number }}
id: deploy-preview
message: "🪓 PR closed, deleted preview at https://github.com/dipy/preview-html/tree/main/${{ env.PR_PATH }}/"

0 comments on commit 27e38df

Please sign in to comment.