diff --git a/.github/workflows/deploy-documentation-preview.yml b/.github/workflows/deploy-documentation-preview.yml index 97566040352..1b223a7562e 100644 --- a/.github/workflows/deploy-documentation-preview.yml +++ b/.github/workflows/deploy-documentation-preview.yml @@ -5,25 +5,27 @@ on: branches: [ "master" ] paths: - 'docs/**' + - '.github/workflows/deploy-documentation-preview.yml' jobs: - build-documentation-preview: + build-and-deploy-documentation-preview: # We could add a check to only rerun if docs have changed since last run on the PR # But this would require a state storage, and the current version is good enough. if: "! contains(github.event.pull_request.labels.*.name, 'pause-pages')" environment: name: pr-documentation-${{ github.event.pull_request.number }} - url: https://hydephp.github.io/develop/pr-${{ github.event.pull_request.number }}/dev-docs-preview + url: https://ci.hydephp.com/previews/develop/${{ github.event.pull_request.number }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: shivammathur/setup-php@v2 - with: - php-version: "8.1" +# Disabled as it should not be necessary, and it takes a long time to run +# - uses: shivammathur/setup-php@v2 +# with: +# php-version: "8.1" - name: Cache Composer packages id: composer-cache @@ -49,7 +51,7 @@ jobs: - name: Update configuration files run: | echo "output_directories:" >> hyde.yml - echo " Hyde\Pages\DocumentationPage: dev-docs-preview" >> hyde.yml + echo " Hyde\Pages\DocumentationPage: ''" >> hyde.yml sed -i "s/'header' => env('SITE_NAME', 'HydePHP').' Docs'/'header' => 'PR #${{ github.event.pull_request.number }} - Docs'/g" config/docs.php - name: Remove published article component @@ -87,7 +89,7 @@ jobs: - name: Configure environment variables run: | echo 'SITE_NAME="HydePHP Documentation Preview"' >> .env - echo 'SITE_URL="https://hydephp.github.io/develop/pr-${{ github.event.pull_request.number }}/dev-docs-preview"' >> .env + echo 'SITE_URL="https://ci.hydephp.com/previews/develop/${{ github.event.pull_request.number }}"' >> .env - name: Move documentation files run: rm -rf _docs && mv -f docs _docs @@ -95,38 +97,28 @@ jobs: - name: Compile the static site run: php hyde build - - name: Upload artifacts - uses: actions/upload-artifact@v1 - with: - name: 'preview-docs' - path: '_site/dev-docs-preview' - - - upload-generated-site: - - runs-on: ubuntu-latest - needs: - - build-documentation-preview - - steps: - - uses: actions/checkout@v3 - with: - ref: 'gh-pages' + - name: Package the static site + run: zip -r site.zip _site - - name: Reset output directories + - name: Sign the artifact run: | - rm -rf pr-${{ github.event.pull_request.number }}/dev-docs-preview - mkdir -p pr-${{ github.event.pull_request.number }}/dev-docs-preview + echo '${{ secrets.CI_PREVIEW_SIGNING_RSA_PRIVATE_KEY }}' > private.pem + openssl dgst -sha256 -sign private.pem -out signature.bin site.zip + unlink private.pem - - name: Download documentation artifact - uses: actions/download-artifact@v3 - with: - name: preview-docs - path: pr-${{ github.event.pull_request.number }}/dev-docs-preview - - - name: Commit changes - uses: EndBug/add-and-commit@v9 - with: - pull: 'origin gh-pages' - add: 'pr-${{ github.event.pull_request.number }}/dev-docs-preview' - message: 'Upload documentation preview for PR ${{ github.event.pull_request.number }}' + - name: Upload the artifact + run: | + repository="develop" + bearerToken="${{ secrets.CI_SERVER_TOKEN }}" + pullRequest="${{ github.event.pull_request.number }}" + signature="$(openssl base64 -in signature.bin)" + artifact="site.zip" + + curl -X POST --fail-with-body \ + -H "Content-Type: multipart/form-data" \ + -H "Authorization: Bearer $bearerToken" \ + -F "repository=$repository" \ + -F "pullRequest=$pullRequest" \ + -F "artifact=@$artifact" \ + -F "signature=$signature" \ + https://ci.hydephp.com/api/deployment-previews