|
| 1 | +name: CI (AdHoc) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +env: |
| 7 | + GCHAT_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_GCHAT_WEBHOOK_URL }} |
| 8 | + DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} |
| 9 | + COMMIT_OWNER: ${{ github.event.pusher.name }} |
| 10 | + COMMIT_SHA: ${{ github.sha }} |
| 11 | + ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} |
| 12 | + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} |
| 13 | + GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + prerequisites: |
| 17 | + name: Pre-requisites for building |
| 18 | + runs-on: ubuntu-latest |
| 19 | + if: github.repository == 'spring-projects/spring-pulsar' |
| 20 | + outputs: |
| 21 | + runjobs: ${{ steps.continue.outputs.runjobs }} |
| 22 | + project_version: ${{ steps.continue.outputs.project_version }} |
| 23 | + boot_version: ${{ steps.continue.outputs.boot_version }} |
| 24 | + should_deploy_artifacts: ${{ steps.should-deploy-artifacts.outputs.result }} |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + - id: continue |
| 28 | + name: Determine if should continue |
| 29 | + run: | |
| 30 | + # Run jobs if in upstream repository |
| 31 | + echo "runjobs=true" >>$GITHUB_OUTPUT |
| 32 | + # Extract version from gradle.properties |
| 33 | + version=$(cat gradle.properties | grep "version=" | awk -F'=' '{print $2}') |
| 34 | + echo "project_version=$version" >>$GITHUB_OUTPUT |
| 35 | + bootVersion=$(cat gradle/libs.versions.toml | grep "spring-boot = \"" | cut -d '"' -f2) |
| 36 | + echo "boot_version=$bootVersion" >>$GITHUB_OUTPUT |
| 37 | + - id: should-deploy-artifacts |
| 38 | + name: Check Deploy Artifacts using Secrets |
| 39 | + if: ${{ runner.os == 'Linux' }} |
| 40 | + run: | |
| 41 | + if [[ -z "$ARTIFACTORY_PASSWORD" ]] ; then |
| 42 | + echo "result=false" >> $GITHUB_OUTPUT |
| 43 | + else |
| 44 | + echo "result=true" >> $GITHUB_OUTPUT |
| 45 | + fi |
| 46 | + deploy_artifacts: |
| 47 | + name: Deploy Artifacts |
| 48 | + needs: [prerequisites] |
| 49 | + runs-on: ubuntu-latest |
| 50 | + if: ${{ needs.prerequisites.outputs.should_deploy_artifacts }} |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + - uses: spring-io/spring-gradle-build-action@v2 |
| 54 | + - id: branch-name |
| 55 | + name: Extract Branch Name |
| 56 | + env: |
| 57 | + BRANCH: ${{ github.ref_name }} |
| 58 | + VERSION: ${{ needs.prerequisites.outputs.project_version }} |
| 59 | + run: | |
| 60 | + branch=$BRANCH |
| 61 | + if [[ "$branch" = "main" ]] ; then |
| 62 | + branch="${VERSION%.*}.x" |
| 63 | + fi |
| 64 | + echo "branch=$branch" >> $GITHUB_OUTPUT |
| 65 | + - id: deploy-location |
| 66 | + name: Default the Deploy Location |
| 67 | + env: |
| 68 | + VERSION: ${{ needs.prerequisites.outputs.project_version }} |
| 69 | + run: | |
| 70 | + if [[ "$VERSION" =~ "-SNAPSHOT" ]] ; then |
| 71 | + deploy_location=artifactory |
| 72 | + else |
| 73 | + deploy_location=central |
| 74 | + fi |
| 75 | + echo "deploy_location=$deploy_location" >> $GITHUB_OUTPUT |
| 76 | + - name: Publish artifacts (Artifactory or staged for Central) |
| 77 | + env: |
| 78 | + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }} |
| 79 | + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }} |
| 80 | + ARTIFACTORY_BUILD_NAME: ${{ github.event.repository.name }}-${{ steps.branch-name.outputs.branch }} |
| 81 | + ARTIFACTORY_BUILD_NUMBER: ${{ github.run_id }} |
| 82 | + ARTIFACTORY_BUILD_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 83 | + ARTIFACTORY_USER_AGENT_NAME: GitHub Actions |
| 84 | + ARTIFACTORY_USER_AGENT_VERSION: Unknown |
| 85 | + ARTIFACTORY_VCS_REVISION: ${{ github.sha } |
| 86 | + run: | |
| 87 | + ./gradlew publishArtifacts \ |
| 88 | + --stacktrace \ |
| 89 | + -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" |
| 90 | + deploy_docs_antora: |
| 91 | + name: Deploy Antora Docs |
| 92 | + needs: [prerequisites] |
| 93 | + runs-on: ubuntu-latest |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v4 |
| 96 | + - uses: spring-io/spring-gradle-build-action@v2 |
| 97 | + - name: Run Antora |
| 98 | + run: | |
| 99 | + ./gradlew antora |
| 100 | + - name: Publish Docs |
| 101 | + uses: spring-io/spring-doc-actions/[email protected] |
| 102 | + with: |
| 103 | + docs-username: ${{ secrets.DOCS_USERNAME }} |
| 104 | + docs-host: ${{ secrets.DOCS_HOST }} |
| 105 | + docs-ssh-key: ${{ secrets.DOCS_SSH_KEY }} |
| 106 | + docs-ssh-host-key: ${{ secrets.DOCS_SSH_HOST_KEY }} |
| 107 | + site-path: spring-pulsar-docs/build/site |
| 108 | + - name: Bust Clouflare Cache |
| 109 | + uses: spring-io/spring-doc-actions/[email protected] |
| 110 | + with: |
| 111 | + context-root: spring-pulsar |
| 112 | + cloudflare-zone-id: ${{ secrets.CLOUDFLARE_ZONE_ID }} |
| 113 | + cloudflare-cache-token: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} |
0 commit comments