Add GitHub Pages p2 publish workflow (#13) #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish p2 Update Site | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out source | |
| uses: actions/checkout@v4 | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "temurin" | |
| java-version: "17" | |
| cache: "maven" | |
| - name: Build p2 repository with Tycho | |
| run: mvn -V -B -DskipTests=false clean verify | |
| - name: Configure GitHub Pages | |
| id: pages | |
| uses: actions/configure-pages@v5 | |
| - name: Prepare site content | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| repo_dir="repository/target/repository" | |
| if [ ! -d "${repo_dir}" ]; then | |
| echo "Expected p2 repository not found at ${repo_dir}." >&2 | |
| exit 1 | |
| fi | |
| site_dir="site" | |
| rm -rf "${site_dir}" | |
| mkdir -p "${site_dir}" | |
| # Publish the repository root at the Pages root. | |
| cp -a "${repo_dir}/." "${site_dir}/" | |
| # If this is a tag build, also publish a versioned path and update /latest/. | |
| if [ "${GITHUB_REF_TYPE}" = "tag" ]; then | |
| mkdir -p "${site_dir}/releases/${GITHUB_REF_NAME}" "${site_dir}/latest" | |
| cp -a "${repo_dir}/." "${site_dir}/releases/${GITHUB_REF_NAME}/" | |
| cp -a "${repo_dir}/." "${site_dir}/latest/" | |
| fi | |
| cat > "${site_dir}/index.html" <<EOF | |
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <title>Eclipse p2 Update Site</title> | |
| </head> | |
| <body> | |
| <h1>Eclipse p2 Update Site</h1> | |
| <p>Use this URL in Eclipse Install New Software:</p> | |
| <p><code>${{ steps.pages.outputs.base_url }}/</code></p> | |
| </body> | |
| </html> | |
| EOF | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: site | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deploy.outputs.page_url }} | |
| permissions: | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deploy | |
| uses: actions/deploy-pages@v4 |