From e2132126f93d8042d56e2292f1a2b2710b58a5d5 Mon Sep 17 00:00:00 2001 From: Daniel Colina Date: Wed, 30 Oct 2024 14:17:18 +0100 Subject: [PATCH 1/6] #28550 New action to deploy javadoc artifacts. --- .../deploy-artifact-javadoc/action.yml | 78 +++++++++++++++++++ .../actions/core-cicd/maven-job/action.yml | 2 + 2 files changed, 80 insertions(+) create mode 100644 .github/actions/core-cicd/deployment/deploy-artifact-javadoc/action.yml diff --git a/.github/actions/core-cicd/deployment/deploy-artifact-javadoc/action.yml b/.github/actions/core-cicd/deployment/deploy-artifact-javadoc/action.yml new file mode 100644 index 000000000000..a544a034dee2 --- /dev/null +++ b/.github/actions/core-cicd/deployment/deploy-artifact-javadoc/action.yml @@ -0,0 +1,78 @@ +name: Deploy Artifact Javadoc +description: Deploys the Javadoc artifact to the GitHub Packages registry +inputs: + ref: + description: 'Branch to build from' + required: false + default: 'main' + github-token: + description: 'GitHub Token' + required: true + release-version: + description: 'The version of the release' + required: true + artifact-run-id: + description: 'The run id of the core artifacts' + aws-access-key-id: + description: 'AWS Access Key ID' + required: true + aws-secret-access-key: + description: 'AWS Secret Access Key' + required: true + aws-region: + description: 'AWS region' + default: 'us-east-1' + required: true + +runs: + using: "composite" + steps: + - name: 'Checkout' + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + + - uses: ./.github/actions/core-cicd/maven-job + id: maven-clean + with: + stage-name: "Clean Build" + maven-args: "clean install -DskipTests" + generate-docker: false + cleanup-runner: true + github-token: ${{ inputs.github-token }} + if: inputs.artifact-run-id == '' + + - uses: ./.github/actions/core-cicd/maven-job + id: maven-javadoc + with: + stage-name: "Deploy Javadoc" + maven-args: "javadoc:javadoc -pl :dotcms-core" + generate-docker: false + cleanup-runner: true + restore-classes: true + artifacts-from: ${{ inputs.artifact-run-id }} + github-token: ${{ inputs.github-token }} + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ inputs.aws-access-key-id }} + aws-secret-access-key: ${{ inputs.aws-secret-access-key }} + aws-region: ${{ inputs.aws-region }} + + - name: Generate/Push Javadoc + if: success() + run: | + echo "::group::Generate/Push Javadoc" + site_dir=./dotCMS/target/site + javadoc_dir=${site_dir}/javadocs + s3_uri=s3://static.dotcms.com/docs/${{ inputs.release-version }}/javadocs + mv ${site_dir}/apidocs ${javadoc_dir} + # ls -R $javadoc_dir + echo "Running: aws s3 cp ${javadoc_dir} ${s3_uri} --recursive" + aws s3 cp ${javadoc_dir} ${s3_uri} --recursive + echo "::endgroup::" + env: + AWS_ACCESS_KEY_ID: ${{ inputs.aws-access-key-id }} + AWS_SECRET_ACCESS_KEY: ${{ inputs.aws-secret-access-key }} + shell: bash \ No newline at end of file diff --git a/.github/actions/core-cicd/maven-job/action.yml b/.github/actions/core-cicd/maven-job/action.yml index 6dc242f04fd7..eade3711b4d9 100644 --- a/.github/actions/core-cicd/maven-job/action.yml +++ b/.github/actions/core-cicd/maven-job/action.yml @@ -259,6 +259,8 @@ runs: name: "build-classes" path: | **/target/classes/**/*.class + **/target/generated-sources/**/*.java + **/target/test-classes/**/*.class LICENSE - id: delete-built-artifacts-from-cache From 5919179246a728b031073048270cc8804af71318 Mon Sep 17 00:00:00 2001 From: Daniel Colina Date: Wed, 30 Oct 2024 14:24:00 +0100 Subject: [PATCH 2/6] #28550 Calling the deploy-javadoc action from release workflow. --- .../legacy-release_maven-release-process.yml | 39 +++++-------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/.github/workflows/legacy-release_maven-release-process.yml b/.github/workflows/legacy-release_maven-release-process.yml index 5f5050d36fb8..0288d73cd701 100644 --- a/.github/workflows/legacy-release_maven-release-process.yml +++ b/.github/workflows/legacy-release_maven-release-process.yml @@ -275,13 +275,6 @@ jobs: with: servers: '[{ "id": "dotcms-libs-local", "username": "${{ secrets.EE_REPO_USERNAME }}", "password": "${{ secrets.EE_REPO_PASSWORD }}" }]' - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} - - name: Deploy Release run: | ./mvnw -ntp \ @@ -293,28 +286,16 @@ jobs: if: github.event.inputs.deploy_artifact == 'true' - name: Generate/Push Javadoc - run: | - ./mvnw -ntp \ - ${JVM_TEST_MAVEN_OPTS} \ - javadoc:javadoc \ - -pl :dotcms-core - rc=$? - if [[ $rc != 0 ]]; then - echo "Javadoc generation failed with exit code $rc" - exit $rc - fi - - site_dir=./dotCMS/target/site - javadoc_dir=${site_dir}/javadocs - s3_uri=s3://static.dotcms.com/docs/${{ needs.prepare-release.outputs.release_version }}/javadocs - - mv ${site_dir}/apidocs ${javadoc_dir} - echo "Running: aws s3 cp ${javadoc_dir} ${s3_uri} --recursive" - aws s3 cp ${javadoc_dir} ${s3_uri} --recursive - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - if: github.event.inputs.upload_javadocs == 'true' + uses: ./.github/actions/core-cicd/deployment/deploy-artifact-javadoc + with: + ref: ${{ github.ref }} + github-token: ${{ secrets.GITHUB_TOKEN }} + artifact-run-id: ${{ github.run_id }} + release-version: ${{ inputs.release_version }} + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + if: github.event.inputs.upload_javadocs == 'true' - name: Update Plugins run: | From ce00b6ff86f954137188f8b91851532d0bdd6a70 Mon Sep 17 00:00:00 2001 From: Daniel Colina Date: Wed, 30 Oct 2024 14:25:32 +0100 Subject: [PATCH 3/6] #28550 renaming action. --- .../{deploy-artifact-javadoc => deploy-javadoc}/action.yml | 0 .github/workflows/legacy-release_maven-release-process.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/actions/core-cicd/deployment/{deploy-artifact-javadoc => deploy-javadoc}/action.yml (100%) diff --git a/.github/actions/core-cicd/deployment/deploy-artifact-javadoc/action.yml b/.github/actions/core-cicd/deployment/deploy-javadoc/action.yml similarity index 100% rename from .github/actions/core-cicd/deployment/deploy-artifact-javadoc/action.yml rename to .github/actions/core-cicd/deployment/deploy-javadoc/action.yml diff --git a/.github/workflows/legacy-release_maven-release-process.yml b/.github/workflows/legacy-release_maven-release-process.yml index 0288d73cd701..5c7ec7d9dd6b 100644 --- a/.github/workflows/legacy-release_maven-release-process.yml +++ b/.github/workflows/legacy-release_maven-release-process.yml @@ -286,7 +286,7 @@ jobs: if: github.event.inputs.deploy_artifact == 'true' - name: Generate/Push Javadoc - uses: ./.github/actions/core-cicd/deployment/deploy-artifact-javadoc + uses: ./.github/actions/core-cicd/deployment/deploy-javadoc with: ref: ${{ github.ref }} github-token: ${{ secrets.GITHUB_TOKEN }} From c6dfd9dd2c3a5e595217b44f890331a2d815f50d Mon Sep 17 00:00:00 2001 From: Daniel Colina Date: Thu, 31 Oct 2024 13:15:05 +0100 Subject: [PATCH 4/6] #28550 restoring legacy-release process workflow. --- .../legacy-release_maven-release-process.yml | 41 ++++++++++++++----- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/.github/workflows/legacy-release_maven-release-process.yml b/.github/workflows/legacy-release_maven-release-process.yml index 5c7ec7d9dd6b..9959dbcdfc33 100644 --- a/.github/workflows/legacy-release_maven-release-process.yml +++ b/.github/workflows/legacy-release_maven-release-process.yml @@ -275,6 +275,13 @@ jobs: with: servers: '[{ "id": "dotcms-libs-local", "username": "${{ secrets.EE_REPO_USERNAME }}", "password": "${{ secrets.EE_REPO_PASSWORD }}" }]' + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + - name: Deploy Release run: | ./mvnw -ntp \ @@ -286,16 +293,28 @@ jobs: if: github.event.inputs.deploy_artifact == 'true' - name: Generate/Push Javadoc - uses: ./.github/actions/core-cicd/deployment/deploy-javadoc - with: - ref: ${{ github.ref }} - github-token: ${{ secrets.GITHUB_TOKEN }} - artifact-run-id: ${{ github.run_id }} - release-version: ${{ inputs.release_version }} - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} - if: github.event.inputs.upload_javadocs == 'true' + run: | + ./mvnw -ntp \ + ${JVM_TEST_MAVEN_OPTS} \ + javadoc:javadoc \ + -pl :dotcms-core + rc=$? + if [[ $rc != 0 ]]; then + echo "Javadoc generation failed with exit code $rc" + exit $rc + fi + + site_dir=./dotCMS/target/site + javadoc_dir=${site_dir}/javadocs + s3_uri=s3://static.dotcms.com/docs/${{ needs.prepare-release.outputs.release_version }}/javadocs + + mv ${site_dir}/apidocs ${javadoc_dir} + echo "Running: aws s3 cp ${javadoc_dir} ${s3_uri} --recursive" + aws s3 cp ${javadoc_dir} ${s3_uri} --recursive + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + if: github.event.inputs.upload_javadocs == 'true' - name: Update Plugins run: | @@ -414,4 +433,4 @@ jobs: SLACK_FOOTER: "" SLACK_ICON: https://avatars.slack-edge.com/temp/2021-12-08/2830145934625_e4e464d502865ff576e4.png SLACK_MESSAGE: " This automated script is excited to announce the release of a new version of dotCMS `${{ needs.prepare-release.outputs.release_version }}` :rocket:\n:docker: Produced images: [${{ needs.build-push-image.outputs.formatted_tags }}]" - if: success() && github.event.inputs.notify_slack == 'true' + if: success() && github.event.inputs.notify_slack == 'true' \ No newline at end of file From 93fcd56027ac73598d852453d3fbb541b06b4199 Mon Sep 17 00:00:00 2001 From: Daniel Colina Date: Thu, 31 Oct 2024 14:53:19 +0100 Subject: [PATCH 5/6] #28550 Adding action documentation. --- .../deployment/deploy-javadoc/README.md | 67 +++++++++++++++++++ .../legacy-release_maven-release-process.yml | 3 +- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 .github/actions/core-cicd/deployment/deploy-javadoc/README.md diff --git a/.github/actions/core-cicd/deployment/deploy-javadoc/README.md b/.github/actions/core-cicd/deployment/deploy-javadoc/README.md new file mode 100644 index 000000000000..a8ba7e898d02 --- /dev/null +++ b/.github/actions/core-cicd/deployment/deploy-javadoc/README.md @@ -0,0 +1,67 @@ +# Deploy Artifact Javadoc Composite Action + +This GitHub composite action deploys Javadoc artifacts to the GitHub Packages registry and an AWS S3 bucket. It uses Maven to generate the Javadocs and AWS CLI to upload the generated documentation to a specified S3 URI. + +## Inputs + +- **ref**: + *Description*: Branch to build from. + *Required*: No + *Default*: `main` + +- **github-token**: + *Description*: GitHub Token for authentication. + *Required*: Yes + +- **release-version**: + *Description*: The version of the release. + *Required*: Yes + +- **artifact-run-id**: + *Description*: The run ID of the core artifacts to restore classes from. + *Required*: No + +- **aws-access-key-id**: + *Description*: AWS Access Key ID for authentication. + *Required*: Yes + +- **aws-secret-access-key**: + *Description*: AWS Secret Access Key for authentication. + *Required*: Yes + +- **aws-region**: + *Description*: AWS region for deployment. + *Required*: Yes + *Default*: `us-east-1` + +## Steps + +1. **Checkout**: Uses the `actions/checkout@v4` action to check out the specified branch. +2. **Maven Clean Build**: Runs a Maven clean install to build the project (skipping tests), only if `artifact-run-id` is not provided. +3. **Deploy Javadoc**: Runs Maven to generate Javadocs and restores classes from the specified artifact run ID if provided. +4. **Configure AWS Credentials**: Configures AWS credentials using the `aws-actions/configure-aws-credentials@v1` action. +5. **Generate/Push Javadoc**: Uploads the generated Javadoc to an S3 bucket using the AWS CLI. + +## Example Usage + +```yaml +name: Deploy Javadoc Workflow +on: + push: + branches: + - main + +jobs: + deploy-javadoc: + runs-on: ubuntu-latest + steps: + - name: Deploy Artifact Javadoc + uses: ./.github/actions/deploy-artifact-javadoc + with: + ref: 'main' + github-token: ${{ secrets.GITHUB_TOKEN }} + release-version: '1.0.0' + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: 'us-east-1' +``` diff --git a/.github/workflows/legacy-release_maven-release-process.yml b/.github/workflows/legacy-release_maven-release-process.yml index 9959dbcdfc33..49dc875de0d7 100644 --- a/.github/workflows/legacy-release_maven-release-process.yml +++ b/.github/workflows/legacy-release_maven-release-process.yml @@ -433,4 +433,5 @@ jobs: SLACK_FOOTER: "" SLACK_ICON: https://avatars.slack-edge.com/temp/2021-12-08/2830145934625_e4e464d502865ff576e4.png SLACK_MESSAGE: " This automated script is excited to announce the release of a new version of dotCMS `${{ needs.prepare-release.outputs.release_version }}` :rocket:\n:docker: Produced images: [${{ needs.build-push-image.outputs.formatted_tags }}]" - if: success() && github.event.inputs.notify_slack == 'true' \ No newline at end of file + if: success() && github.event.inputs.notify_slack == 'true' + \ No newline at end of file From d02a00aaa1b8720094bf50d05550d597fa7cbd44 Mon Sep 17 00:00:00 2001 From: Daniel Colina Date: Thu, 31 Oct 2024 14:56:51 +0100 Subject: [PATCH 6/6] #28550 Updating action documentation. --- .../actions/core-cicd/deployment/deploy-javadoc/README.md | 5 +++++ .github/workflows/legacy-release_maven-release-process.yml | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/actions/core-cicd/deployment/deploy-javadoc/README.md b/.github/actions/core-cicd/deployment/deploy-javadoc/README.md index a8ba7e898d02..8cb3cf6ff745 100644 --- a/.github/actions/core-cicd/deployment/deploy-javadoc/README.md +++ b/.github/actions/core-cicd/deployment/deploy-javadoc/README.md @@ -65,3 +65,8 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: 'us-east-1' ``` + +# Notes + +- Ensure that the github-token, aws-access-key-id, and aws-secret-access-key inputs are provided securely using GitHub secrets. +- The artifact-run-id is optional and can be used to restore classes from previous artifact runs if necessary. diff --git a/.github/workflows/legacy-release_maven-release-process.yml b/.github/workflows/legacy-release_maven-release-process.yml index 49dc875de0d7..9959dbcdfc33 100644 --- a/.github/workflows/legacy-release_maven-release-process.yml +++ b/.github/workflows/legacy-release_maven-release-process.yml @@ -433,5 +433,4 @@ jobs: SLACK_FOOTER: "" SLACK_ICON: https://avatars.slack-edge.com/temp/2021-12-08/2830145934625_e4e464d502865ff576e4.png SLACK_MESSAGE: " This automated script is excited to announce the release of a new version of dotCMS `${{ needs.prepare-release.outputs.release_version }}` :rocket:\n:docker: Produced images: [${{ needs.build-push-image.outputs.formatted_tags }}]" - if: success() && github.event.inputs.notify_slack == 'true' - \ No newline at end of file + if: success() && github.event.inputs.notify_slack == 'true' \ No newline at end of file