From 8a0c8e44c8d3e446b83f46a282b81c4f1714efd9 Mon Sep 17 00:00:00 2001 From: Tri Nguyen Date: Tue, 17 Sep 2024 10:01:36 -0700 Subject: [PATCH] Testing final workflow changes --- .github/workflows/build.yml | 51 ++++++++++------------------------ .github/workflows/close-pr.yml | 31 +++++++++++++++++++++ 2 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/close-pr.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 85172ca..a4c8f47 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,11 @@ on: push: branches: [ "refractor" ] pull_request: - branches: [ "master" ] + branches: ["master"] + types: + - opened + - synchronize + - reopened jobs: build: @@ -61,43 +65,18 @@ jobs: run: make doxygen_generate - name: Install rsync run: apt install -y rsync + - name: Set target-folder + id: set-folder + run: | + if [ "${{ github.ref_name }}" = "main" ]; then + echo "TARGET_FOLDER=/" + else + echo "TARGET_FOLDER=${github.ref_name}/" + fi + shell: bash - name: Upload Pages Artifact uses: JamesIves/github-pages-deploy-action@v4 with: branch: documentation folder: build/documentation/ - target-folder: ${{ github.ref_name }}/ - - # documentation-upload: - # needs: documentation - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # with: - # ref: documentation - # - name: Build with Jekyll - # uses: actions/jekyll-build-pages@v1 - # with: - # verbose: true - # - name: Upload Pages Artifact - # uses: actions/upload-pages-artifact@v3 - - # documentation-deploy: - # needs: documentation-upload - - # # Grant GITHUB_TOKEN the permissions required to make a Pages deployment - # permissions: - # pages: write # to deploy to Pages - # id-token: write # to verify the deployment originates from an appropriate source - - # # Deploy to the github-pages environment - # environment: - # name: github-pages - # url: ${{ steps.deployment.outputs.page_url }} - - # # Specify runner + deployment step - # runs-on: ubuntu-latest - # steps: - # - name: Deploy to GitHub Pages - # id: deployment - # uses: actions/deploy-pages@v4 \ No newline at end of file + target-folder: ${{ steps.set-folder.outputs.TARGET_FOLDER }}/ \ No newline at end of file diff --git a/.github/workflows/close-pr.yml b/.github/workflows/close-pr.yml new file mode 100644 index 0000000..5133649 --- /dev/null +++ b/.github/workflows/close-pr.yml @@ -0,0 +1,31 @@ +name: Cleanup PR + +on: + pull_request: + types: + - closed + +jobs: + cleanup: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: documentation + - name: Delete coverage/documentation for ${{ github.head_ref }} from documentation branch + run: | + folder_to_delete="${{ github.head_ref }}" + echo "Deleting folder: $folder_to_delete from documentation" + rm -rf "$folder_to_delete" + git rm -r "$folder_to_delete" || true + - name: Configure Git for Pushing Deletion change + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + - name: PUshing Deletion Change + run: | + pr = ${{ github.event.pull_request.number }} + git commit -m "Remove folder ${{ github.head_ref }} from documentation branch after PR ${pr} was closed" + git push origin ${{ github.head_ref }}