Skip to content

Commit

Permalink
build: simplify GitHub Pages deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
kris7t committed Nov 5, 2024
1 parent b97cd57 commit 1880843
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 87 deletions.
99 changes: 28 additions & 71 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,40 +79,36 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
./gradlew sonar -Pci --info --stacktrace --max-workers 4 --no-daemon
- name: Upload application artifacts
if: ${{ matrix.os == 'ubuntu-20.04' }}
uses: actions/upload-artifact@v4
with:
name: distributions
path: subprojects/**/build/distributions/*.tar
compression-level: 0
retention-days: 5 # No need to preserve for long, since they are uploaded to GHCR
- name: Build signed Maven repository
if: ${{ matrix.os == 'ubuntu-20.04' && github.event_name == 'push' && github.repository_owner == 'graphs4value' }}
env:
PGP_KEY: ${{ secrets.PGP_KEY }}
PGP_KEY_ID: ${{ secrets.PGP_KEY_ID }}
PGP_PASSWORD: ${{ secrets.PGP_PASSWORD }}
run: |
./gradlew mavenRepositoryTar -Pci -PforceSign --info --stacktrace --max-workers 4 --no-daemon
./gradlew mavenRepository -Pci -PforceSign --info --stacktrace --max-workers 4 --no-daemon
- name: Build unsigned Maven repository
if: ${{ matrix.os == 'ubuntu-20.04' && (github.event_name != 'push' || github.repository_owner != 'graphs4value') }}
run: |
./gradlew mavenRepositoryTar -Pci --info --stacktrace --max-workers 4 --no-daemon
- name: Upload Maven repository artifact
if: ${{ matrix.os == 'ubuntu-20.04' }}
uses: actions/upload-artifact@v4
with:
name: maven-repository-tar
path: build/refinery-maven-repository.tar
compression-level: 0
- name: Upload application artifacts
./gradlew mavenRepository -Pci --info --stacktrace --max-workers 4 --no-daemon
- name: Merge Maven repository with site
if: ${{ matrix.os == 'ubuntu-20.04' }}
uses: actions/upload-artifact@v4
with:
name: distributions-tar
path: subprojects/**/build/distributions/*.tar
compression-level: 0
retention-days: 5 # No need to preserve for long, since they are uploaded to GHCR
- name: Upload site artifact
run: |
mv build/repo subprojects/docs/build/docusaurus/maven
- name: Upload GithHub Pages artifact
if: ${{ matrix.os == 'ubuntu-20.04' }}
uses: actions/upload-artifact@v4
uses: actions/upload-pages-artifact@v3
with:
name: site-zip
path: subprojects/docs/build/refinery-docs.zip
compression-level: 0
path: subprojects/docs/build/docusaurus/
retention-days: 90
reuse-check:
name: REUSE Compliance Check
permissions:
Expand All @@ -129,56 +125,17 @@ jobs:
name: Publish to GitHub Pages
if: ${{ github.event_name == 'push' && github.ref_name == 'main' && github.repository == 'graphs4value/refinery' }}
needs: build
permissions:
pages: write
id-token: write
runs-on: ubuntu-20.04
environment:
name: github-pages
url: ${{steps.deployment.outputs.page_url}}
steps:
- name: Download site artifact
uses: actions/download-artifact@v4
with:
name: site-zip
path: site-zip
- name: Download Maven repository artifact
uses: actions/download-artifact@v4
with:
name: maven-repository-tar
path: maven-repository-tar
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@ea88154188003ca5aeb616063b2d0dd6a9cf86e2
with:
gpg_private_key: ${{ secrets.PGP_KEY }}
fingerprint: ${{ secrets.PGP_FINGERPRINT }}
passphrase: ${{ secrets.PGP_PASSWORD }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Create empty git repository
run: |
mkdir graphs4value.github.io
cd graphs4value.github.io
git config --global init.defaultBranch main
git config --global user.name "Graphs4Value bot"
git config --global user.email "refinery@refinery.tools"
git init
- name: Extract site artifact
working-directory: ./graphs4value.github.io
run: |
unzip ../site-zip/refinery-docs.zip
- name: Extract Maven repository artifact
working-directory: ./graphs4value.github.io
run: |
mkdir -p maven/snapshots
cd maven/snapshots
tar -xvf ../../../maven-repository-tar/refinery-maven-repository.tar
- name: Commit and push to graphs4value.github.io
working-directory: ./graphs4value.github.io
env:
GH_PAGES_TOKEN: ${{ secrets.GH_PAGES_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
run: |
git remote add origin "https://x-access-token:${GH_PAGES_TOKEN}@github.com/graphs4value/graphs4value.github.io.git"
git add .
git commit -S -m "Update from https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}"
git push --force origin main
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
docker-build:
name: Build Docker images
needs: build
Expand All @@ -200,7 +157,7 @@ jobs:
- name: Download application artifacts
uses: actions/download-artifact@v4
with:
name: distributions-tar
name: distributions
path: subprojects
- name: Extract application artifacts
working-directory: ./docker
Expand All @@ -225,4 +182,4 @@ jobs:
- name: Delete application artifacts
uses: geekyeggo/delete-artifact@24928e75e6e6590170563b8ddae9fac674508aa1
with:
name: distributions-tar
name: distributions
7 changes: 2 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,12 @@ val cleanMavenRepository by tasks.registering(Delete::class) {
delete(mavenRepositoryDir)
}

val mavenRepositoryTar by tasks.registering(Tar::class) {
val mavenRepository by tasks.registering(Task::class) {
dependsOn(cleanMavenRepository)
from(mavenRepositoryDir)
archiveFileName = "refinery-maven-repository.tar"
destinationDirectory = layout.buildDirectory
}

gradle.projectsEvaluated {
mavenRepositoryTar.configure {
mavenRepository.configure {
for (subproject in rootProject.subprojects) {
if (subproject.plugins.hasPlugin(MavenPublishPlugin::class)) {
dependsOn(subproject.tasks.named("publishMavenJavaPublicationToFileRepository"))
Expand Down
11 changes: 0 additions & 11 deletions subprojects/docs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,6 @@ tasks {
delete(".docusaurus")
delete(".yarn")
}

val siteZip by registering(Zip::class) {
dependsOn(assembleFrontend)
from(docusaurusOutputDir)
archiveFileName = "refinery-docs.zip"
destinationDirectory = layout.buildDirectory
}

assemble {
dependsOn(siteZip)
}
}

sonarqube.properties {
Expand Down

0 comments on commit 1880843

Please sign in to comment.