From 69c63afa0a4bbea6debb28b4f2472112a98a7049 Mon Sep 17 00:00:00 2001 From: Stefan Utamaru Date: Sun, 24 Nov 2024 17:37:51 +0900 Subject: [PATCH 1/9] wip: try creating a GitHub Actions workflow file --- .github/workflows/branch-preview.yaml | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/branch-preview.yaml diff --git a/.github/workflows/branch-preview.yaml b/.github/workflows/branch-preview.yaml new file mode 100644 index 00000000000..495da09dc67 --- /dev/null +++ b/.github/workflows/branch-preview.yaml @@ -0,0 +1,29 @@ +name: Deploy Pull Request to GitHub Pages + +on: + pull_request: + types: + - opened + - synchronize + - reopened + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout doc-ja + uses: actions/checkout@v4 + with: + path: doc-ja + + - name: Checkout phd + uses: actions/checkout@v4 + with: + repository: phd/phd + path: phd + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + From f187c21d553bc256267fc904e369d22306d703c5 Mon Sep 17 00:00:00 2001 From: Stefan Utamaru Date: Sun, 24 Nov 2024 17:46:45 +0900 Subject: [PATCH 2/9] try the remaining steps of building the environment --- .github/workflows/branch-preview.yaml | 46 +++++++++++++++++++-------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/.github/workflows/branch-preview.yaml b/.github/workflows/branch-preview.yaml index 495da09dc67..7619b5c91fd 100644 --- a/.github/workflows/branch-preview.yaml +++ b/.github/workflows/branch-preview.yaml @@ -11,19 +11,39 @@ jobs: build-and-deploy: runs-on: ubuntu-latest steps: - - name: Checkout doc-ja - uses: actions/checkout@v4 - with: - path: doc-ja + - name: Checkout phd + uses: actions/checkout@v4 + with: + repository: php/phd + path: phd + + - name: Checkout doc-base + uses: actions/checkout@v4 + with: + repository: php/doc-base + path: doc-base - - name: Checkout phd - uses: actions/checkout@v4 - with: - repository: phd/phd - path: phd + - name: Checkout doc-en + uses: actions/checkout@v4 + with: + repository: php/doc-en + path: doc-en - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' + - name: Checkout doc-ja + uses: actions/checkout@v4 + with: + path: doc-ja + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + + - name: Validate and build .manual.xml + run: | + php doc-base/configure.php --with-lang=ja + + - name: Render xhtml + run: | + php phd/render.php --docbook doc-base/.manual.xml --package PHP --format xhtml + cat output/php-chunked-xhtml/index.html From 9c3a60755e4e614dc42d0ae4a545259fda2d9b98 Mon Sep 17 00:00:00 2001 From: Stefan Utamaru Date: Sun, 24 Nov 2024 17:50:43 +0900 Subject: [PATCH 3/9] change dir name --- .github/workflows/branch-preview.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/branch-preview.yaml b/.github/workflows/branch-preview.yaml index 7619b5c91fd..e387fa80535 100644 --- a/.github/workflows/branch-preview.yaml +++ b/.github/workflows/branch-preview.yaml @@ -27,12 +27,12 @@ jobs: uses: actions/checkout@v4 with: repository: php/doc-en - path: doc-en + path: en - name: Checkout doc-ja uses: actions/checkout@v4 with: - path: doc-ja + path: ja - name: Set up PHP uses: shivammathur/setup-php@v2 From 9c98ea2b6a1ca1e16e90075b0455d160cafc7f56 Mon Sep 17 00:00:00 2001 From: Stefan Utamaru Date: Sun, 24 Nov 2024 18:22:11 +0900 Subject: [PATCH 4/9] try to deploy to pages --- .github/workflows/branch-preview.yaml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/branch-preview.yaml b/.github/workflows/branch-preview.yaml index e387fa80535..862ec113429 100644 --- a/.github/workflows/branch-preview.yaml +++ b/.github/workflows/branch-preview.yaml @@ -8,7 +8,7 @@ on: - reopened jobs: - build-and-deploy: + build: runs-on: ubuntu-latest steps: - name: Checkout phd @@ -46,4 +46,23 @@ jobs: - name: Render xhtml run: | php phd/render.php --docbook doc-base/.manual.xml --package PHP --format xhtml - cat output/php-chunked-xhtml/index.html + + - name: Upload static files as artifact + id: deployment + uses: actions/upload-pages-artifact@v3 + with: + path: output/php-chunked-xhtml/ + + deploy: + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 From a39a75a6c65cd6fabf113b9f3f98b69e92b5c255 Mon Sep 17 00:00:00 2001 From: Stefan Utamaru Date: Sun, 24 Nov 2024 18:32:27 +0900 Subject: [PATCH 5/9] set branch path --- .github/workflows/branch-preview.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/branch-preview.yaml b/.github/workflows/branch-preview.yaml index 862ec113429..93a9756c911 100644 --- a/.github/workflows/branch-preview.yaml +++ b/.github/workflows/branch-preview.yaml @@ -47,11 +47,17 @@ jobs: run: | php phd/render.php --docbook doc-base/.manual.xml --package PHP --format xhtml + - name: Add Pull Request Path + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + mkdir -p ./output/pr/$PR_NUMBER + mv ./output/php-chunked-xhtml/* ./output/pr/$PR_NUMBER/ + - name: Upload static files as artifact id: deployment uses: actions/upload-pages-artifact@v3 with: - path: output/php-chunked-xhtml/ + path: ./output/ deploy: permissions: From 54447e26578db6d38c798eb7bed88db3b9b35b5a Mon Sep 17 00:00:00 2001 From: Stefan Utamaru Date: Sun, 24 Nov 2024 19:25:59 +0900 Subject: [PATCH 6/9] set retention days to 7 days --- .github/workflows/branch-preview.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/branch-preview.yaml b/.github/workflows/branch-preview.yaml index 93a9756c911..b7b73fa9b8b 100644 --- a/.github/workflows/branch-preview.yaml +++ b/.github/workflows/branch-preview.yaml @@ -58,6 +58,7 @@ jobs: uses: actions/upload-pages-artifact@v3 with: path: ./output/ + retention-days: 7 # 1週間くらい残しておく deploy: permissions: From 5c73384908750fa0c2a4dc1a200ac620185ffad8 Mon Sep 17 00:00:00 2001 From: Stefan Utamaru Date: Sun, 24 Nov 2024 21:51:44 +0900 Subject: [PATCH 7/9] comment GitHub Pages url to PR --- .github/workflows/branch-preview.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/branch-preview.yaml b/.github/workflows/branch-preview.yaml index b7b73fa9b8b..a10208102c7 100644 --- a/.github/workflows/branch-preview.yaml +++ b/.github/workflows/branch-preview.yaml @@ -64,6 +64,7 @@ jobs: permissions: pages: write id-token: write + pull-requests: write environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} @@ -73,3 +74,8 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 + - name: Comment URL to Pull Request + uses: marocchino/sticky-pull-request-comment@v2 + with: + message: | + Deployed ${{ github.sha }} to ${{ steps.deployment.outputs.page_url }}/pr/${{ github.event.pull_request.number }} From 6dbb5b011070b0c543560fa94b6563f89cd59618 Mon Sep 17 00:00:00 2001 From: Stefan Utamaru Date: Sun, 24 Nov 2024 21:57:22 +0900 Subject: [PATCH 8/9] update commented github sha value --- .github/workflows/branch-preview.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/branch-preview.yaml b/.github/workflows/branch-preview.yaml index a10208102c7..e82a1cc4406 100644 --- a/.github/workflows/branch-preview.yaml +++ b/.github/workflows/branch-preview.yaml @@ -78,4 +78,4 @@ jobs: uses: marocchino/sticky-pull-request-comment@v2 with: message: | - Deployed ${{ github.sha }} to ${{ steps.deployment.outputs.page_url }}/pr/${{ github.event.pull_request.number }} + Deployed ${{ github.event.pull_request.head.sha }} to ${{ steps.deployment.outputs.page_url }}/pr/${{ github.event.pull_request.number }} From d0fbafcfdb5bd73081c6a390dcf6532cf3256c6d Mon Sep 17 00:00:00 2001 From: Stefan Utamaru Date: Sun, 24 Nov 2024 22:26:10 +0900 Subject: [PATCH 9/9] remove unnecessary trailing slash --- .github/workflows/branch-preview.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/branch-preview.yaml b/.github/workflows/branch-preview.yaml index e82a1cc4406..bb43691022e 100644 --- a/.github/workflows/branch-preview.yaml +++ b/.github/workflows/branch-preview.yaml @@ -78,4 +78,4 @@ jobs: uses: marocchino/sticky-pull-request-comment@v2 with: message: | - Deployed ${{ github.event.pull_request.head.sha }} to ${{ steps.deployment.outputs.page_url }}/pr/${{ github.event.pull_request.number }} + Deployed ${{ github.event.pull_request.head.sha }} to ${{ steps.deployment.outputs.page_url }}pr/${{ github.event.pull_request.number }}