From 69a86426cd677e1e172e9154bb58f13930985830 Mon Sep 17 00:00:00 2001 From: David Upton Date: Mon, 20 May 2024 15:27:52 -0400 Subject: [PATCH 01/17] DIG-2681 Github Actions --- .github/config/slack/slack-workflow.yml | 69 ++++++++++ .github/config/slack/slack.yml | 127 ++++++++++++++++++ .github/sanitize/README.md | 21 +++ .github/sanitize/publish-excludes.txt | 47 +++++++ .github/sanitize/publish-from.txt | 11 ++ .github/workflows/D10-GenerateRelease.yml | 103 ++++++++++++++ ...releaseNotes.yml => D10-NotifyRelease.yml} | 4 +- 7 files changed, 380 insertions(+), 2 deletions(-) create mode 100644 .github/config/slack/slack-workflow.yml create mode 100644 .github/config/slack/slack.yml create mode 100644 .github/sanitize/README.md create mode 100644 .github/sanitize/publish-excludes.txt create mode 100644 .github/sanitize/publish-from.txt create mode 100644 .github/workflows/D10-GenerateRelease.yml rename .github/workflows/{releaseNotes.yml => D10-NotifyRelease.yml} (84%) diff --git a/.github/config/slack/slack-workflow.yml b/.github/config/slack/slack-workflow.yml new file mode 100644 index 0000000000..96c8c73d96 --- /dev/null +++ b/.github/config/slack/slack-workflow.yml @@ -0,0 +1,69 @@ +username: GitHub-CI +icon_url: https://octodex.github.com/images/femalecodertocat.png + +pretext: Triggered via {{eventName}} by {{actor}} {{default action "action"}} {{ref}} `{{diffRef}}` +title: GitHub Actions +title_link: https://support.github.com + +fallback: |- + [GitHub] {{workflow}} #{{runNumber}} is {{jobStatus}} + +blocks: + # author + - type: context + elements: + - type: image + image_url: '{{{sender.avatar_url}}}' + alt_text: '{{sender.login}}' + - type: mrkdwn + text: "*<{{sender.html_url}}|{{sender.login}}>*" + + # text + - type: section + text: + type: mrkdwn + text: >- + Workflow {{payload.workflow.name}} {{payload.workflow_run.status}} + with {{payload.workflow_run.conclusion}} after + {{pluralize payload.workflow_run.run_attempt 'attempt'}} + accessory: + type: button + text: + type: plain_text + text: View + value: workflow_run_{{payload.workflow_run.workflow_id}} + url: '{{payload.workflow_run.html_url}}' + action_id: button-action + + # fields + - type: section + fields: + - type: mrkdwn + text: "*Jobs*\n{{payload.workflow_run.jobs_url}}" + - type: mrkdwn + text: "*Logs*\n{{payload.workflow_run.logs_url}}" + + # footer + - type: context + elements: + - type: image + image_url: '{{footer_icon}}' + alt_text: github + - type: mrkdwn + text: '{{{footer}}} | ' + +footer: >- + <{{repositoryUrl}}|{{repositoryName}}> {{workflow}} #{{runNumber}} + +colors: + success: '#5DADE2' + failure: '#884EA0' + cancelled: '#A569BD' + default: '#7D3C98' + +icons: + success: ':white_check_mark:' + failure: ':grimacing:' + cancelled: ':x:' + skipped: ':heavy_minus_sign:' + default: ':interrobang:' diff --git a/.github/config/slack/slack.yml b/.github/config/slack/slack.yml new file mode 100644 index 0000000000..da1e981351 --- /dev/null +++ b/.github/config/slack/slack.yml @@ -0,0 +1,127 @@ +username: GitHub-CI +icon_url: https://octodex.github.com/images/femalecodertocat.png + +pretext: Triggered via {{eventName}} by {{actor}} {{default action "action"}} {{ref}} `{{diffRef}}` +title: GitHub Actions +title_link: https://support.github.com + +text: &text | + *<{{workflowRunUrl}}|Workflow _{{workflow}}_ job _{{jobName}}_ triggered by _{{eventName}}_ is _{{jobStatus}}_>* for <{{refUrl}}|`{{ref}}`> + {{#if description}}<{{diffUrl}}|`{{diffRef}}`> - {{{description}}}{{/if}} + {{#if payload.commits}} + *Commits* + {{#each payload.commits}} + <{{this.url}}|`{{truncate this.id 8}}`> - {{this.message}} + {{/each}} + {{/if}} + +fallback: |- + [GitHub] {{workflow}} #{{runNumber}} {{jobName}} is {{jobStatus}} + +fields: + - title: Job Steps + value: "{{#each jobSteps}}{{icon this.outcome}} {{@key}}\n{{/each}}" + short: false + - title: Job Matrix + value: "{{#each jobMatrix}}{{@key}}: {{this}}\n{{/each}}" + short: false + - title: Workflow + value: "<{{{workflowUrl}}}|{{workflow}}>" + short: true + - title: Git Ref + value: "{{ref}} ({{refType}})" + short: true + - title: Run ID + value: |- + <{{workflowRunUrl}}|{{runId}}> + short: true + - title: Run Number + value: "{{runNumber}}" + short: true + - title: Actor + value: "{{actor}}" + short: true + - title: Job Status + value: "{{jobStatus}}" + short: true + +blocks: + # author + - type: context + elements: + - type: image + image_url: '{{{sender.avatar_url}}}' + alt_text: '{{sender.login}}' + - type: mrkdwn + text: "*<{{sender.html_url}}|{{sender.login}}>*" + + # title + - type: section + text: + type: mrkdwn + text: | + *<{{title_link}}|{{title}}>* + + # text + - type: section + text: + type: mrkdwn + text: *text + accessory: + type: button + text: + type: plain_text + text: View + value: workflow_run_{{runId}} + url: '{{workflowRunUrl}}' + action_id: button-action + + # fields + - type: section + fields: + - type: mrkdwn + text: |- + *Job Steps* + {{#each jobSteps}}{{#ifneq this.outcome 'skipped'}}{{icon this.outcome}} {{@key}} + {{/ifneq}}{{/each}} + - type: section + fields: + - type: mrkdwn + text: "*Workflow*\n<{{{workflowUrl}}}|{{workflow}}>" + - type: mrkdwn + text: "*Git Ref*\n{{ref}} ({{refType}})" + - type: mrkdwn + text: |- + *Run ID* + <{{workflowRunUrl}}|{{runId}}> + - type: mrkdwn + text: "*Run Number*\n{{runNumber}}" + - type: mrkdwn + text: "*Actor*\n{{actor}}" + - type: mrkdwn + text: "*Job Status*\n{{jobStatus}}" + + # footer + - type: context + elements: + - type: image + image_url: '{{footer_icon}}' + alt_text: github + - type: mrkdwn + text: '{{{footer}}} | ' + +footer: >- + <{{repositoryUrl}}|{{repositoryName}}> {{workflow}} #{{runNumber}} + +colors: + success: '#5DADE2' + failure: '#884EA0' + cancelled: '#A569BD' + default: '#7D3C98' + +icons: + success: ':white_check_mark:' + failure: ':grimacing:' + cancelled: ':x:' + skipped: ':heavy_minus_sign:' + default: ':interrobang:' diff --git a/.github/sanitize/README.md b/.github/sanitize/README.md new file mode 100644 index 0000000000..b06ea0ef26 --- /dev/null +++ b/.github/sanitize/README.md @@ -0,0 +1,21 @@ +# BOSTON.GOV - Sanitize Read-me +## Purpose +We wish to maintain `open-source` availability of the boston.gov website, allowing Boston residents and like-minded municipalities can view, commenting on and download our Drupal source code. + +These files are used as part of an `rsync` performed when synchronizing the private working repo with the public "open-source" repo. + +## Methodology +While committed to the principles of the open-source community, we cannot publish secret or confidential information. This information typically can be classified environment set-ups, or integrations with third parties. + +We do not publish copies of our database which contains our site content, and possibly data we have an obligation to protect -for example for data privacy reasons. + +The santitize process occurs in a GithubAction found in D10-Publish.yml + +## Public/Private Repo Rationale +We maintain a private working repo: +- So that any confidential/sensitive settings which are accidentially committed do not make their way into a public repo. +- To keep the public repo somewhat managed and "clean". +- To keep the public repo as un-complicated as possible. +- To keep the public repo in line with the production code committed and deployed to Acquia. +- To keep the commit messages and language professional and consistent (templated) between deploys. +- So that release notes and other communications can be formatted suitable for general consumption. diff --git a/.github/sanitize/publish-excludes.txt b/.github/sanitize/publish-excludes.txt new file mode 100644 index 0000000000..b93cbb056a --- /dev/null +++ b/.github/sanitize/publish-excludes.txt @@ -0,0 +1,47 @@ +############################################################ +# Target files known to have sensitive information in them. +# This section can be added as new risks are identified. +############################################################ +**/*/bos_*.settings +**/*/node_*.settings + +############################################################ +# Files which shouldn't be included, but probably don't need +# reviewing often. +############################################################ + +# Remove all the custom settings files +docroot/sites/default/settings +docroot/core +docroot/libraries + +# Remove any Core and Contributed modules +docroot/modules/contributed + +# Remove all folders not in the root +drush +patches +scripts +tests + +# Exclude OS config files +.htaccess +web.config + +# exclude all the non-default config folders +config/acquia_dev +config/acquia_prod +config/acquia_stage +config/local +config/never_import +config/travis + +# Remove the Github actions folders +.github + +# Junk files in the root +.gitignore +.lando.yml +.lando.yml.linux +RELEASE.md +**/*/.gitignore diff --git a/.github/sanitize/publish-from.txt b/.github/sanitize/publish-from.txt new file mode 100644 index 0000000000..2a15145c77 --- /dev/null +++ b/.github/sanitize/publish-from.txt @@ -0,0 +1,11 @@ +############################################################ +# These two folders must be retained. +############################################################ +config +docroot +docroot/modules/custom +############################################################ +# Production environments need composer files. +############################################################ +composer.json +composer.lock diff --git a/.github/workflows/D10-GenerateRelease.yml b/.github/workflows/D10-GenerateRelease.yml new file mode 100644 index 0000000000..54c98a4158 --- /dev/null +++ b/.github/workflows/D10-GenerateRelease.yml @@ -0,0 +1,103 @@ +name: "Generate Release Notes" +on: + workflow_dispatch: + push: + branches: # we can add branches to this list which will deploy code to Acquia GitLab as we push code to those branches. + - production + +env: + GH_TOKEN: ${{ secrets.PUBLISH_GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.PUBLISH_GITHUB_TOKEN }} + +jobs: + MakeRelease: + # installed software: https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + + # Checkout this repo, set remote correctly. + - name: Checkout a repository + if: ${{ vars.TEST_REPO_URL != '' }} + run: | + URL=${{ vars.TEST_REPO_URL }} + URL=${URL/git/${{ secrets.PUBLISH_GITHUB_TOKEN }}} + echo "gh repo clone ${{ vars.TEST_REPO }} /public -- --depth 1 --branch ${GITHUB_REF_NAME}" + gh repo clone ${{ vars.TEST_REPO }} /public -- --depth=1 --branch=$GITHUB_REF_NAME + cd /public + echo "git remote set-url origin $URL" + git remote set-url origin $URL + + - name: Checkout this repository + if: ${{ vars.TEST_REPO_URL == '' }} + uses: actions/checkout@v4 + with: + path: /public + depth: 5 + + # Create some variables for later use. + # Try to make sure our tags align with Acquia tags. + - name: Set environment variables + run: | + cd /public + echo 'pr=$(gh pr list -s merged --head ${{ github.ref_name }} -L 1 ' + pr=$(gh pr list -s merged --head ${{ github.ref_name }} -L 1 | awk '{print $1}' | xargs gh pr view --json title,body) || pr='{"title":"Unknown PR","body":"Cannot find a PR for ${{ github.ref_name }}. "}' + echo "pr=${pr}" >> "${GITHUB_ENV}" + [[ ${{ vars.DEBUG == 1 }} ]] && printf "PR Notes:\n${pr}\n" + count=0 + ACQUIA_TAG=$(date +tags/%Y-%m-%d) + while [[ $(git tag --list | grep $ACQUIA_TAG) ]]; do + ACQUIA_TAG=$(date +tags/%Y-%m-%d).$count + count=$(($count+1)) + ok=$(git tag --list | grep $ACQUIA_TAG) || break + [[ $count -gt 10 ]] && exit 100 + done + echo "ACQUIA_TAG=$ACQUIA_TAG" >> "${GITHUB_ENV}" + echo "RELEASE_NUMBER=v10_$(date +%Y)_${{ vars.COUNT }}" >> "${GITHUB_ENV}" + + # Tag the branch and push to remote. + - name: Tag the branch + run: | + cd /public + git config --global user.email "digital-dev@boston.gov" + git config --global user.name "Github Action" + [ ${{ vars.DRY_RUN }} == 0 ] && \ + git tag -a "${{ env.ACQUIA_TAG }}" -m "${{ env.RELEASE_NUMBER }}" && \ + git push origin ${{ env.ACQUIA_TAG }} || echo "Tag Exists" + exit 1 + + # Create the GitHub PUBLIC repo Release Note. + - name: Generate Release Notes + env: + TITLE: ${{ fromJSON(env.pr).title }} + TICKETS: ${{ fromJSON(env.pr).body }} + RELEASE_NOTES: "[PM to complete]" + WORKING_FILE: "/public/CHANGELOG.md" + DRAFT: 1 # 1 = ReleaseNote is draft - else is published + run: | + cd /public + printf "## ${{ env.TITLE }} + ### Release By + ${{ github.author }} + ### Pull Request By + ${{ github.triggering_author }} + ### Release Notes + ${{ env.RELEASE_NOTES }} + ### Related Jira tickets + ${{ env.TICKETS }} + ### Acquia tags + ${{ env.ACQUIA_TAG }}" > ${{ env.WORKING_FILE }} + options="--latest --generate-notes" + options="$options --notes-start-tag ${{ vars.LAST_TAG }}" + options="$options --notes-file ${{ env.WORKING_FILE }}" + options="$options --title ${{ env.RELEASE_NUMBER }}" + [ ${{ env.DRAFT }} == 1 ] && options="--draft $options" + [ ${{ vars.DRY_RUN }} == 0 ] && gh release create ${{ env.ACQUIA_TAG }} $options + + - name: Save some variables for future runs. + run: | + cd /public + gh variable set COUNT --body $(( ${{ vars.COUNT }}+1 )) + gh variable set LAST_TAG --body ${{ env.ACQUIA_TAG }} diff --git a/.github/workflows/releaseNotes.yml b/.github/workflows/D10-NotifyRelease.yml similarity index 84% rename from .github/workflows/releaseNotes.yml rename to .github/workflows/D10-NotifyRelease.yml index b0e8029aaa..b54329c9a2 100644 --- a/.github/workflows/releaseNotes.yml +++ b/.github/workflows/D10-NotifyRelease.yml @@ -1,4 +1,4 @@ -name: Broadcast Release Notes +name: Broadcast Release Notes (slack) on: release: types: [released] @@ -10,7 +10,7 @@ jobs: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} steps: - name: Checkout - uses: actions/checkout@v3.5.2 + uses: actions/checkout@v3.5.2 - name: Release Notes uses: act10ns/slack@v2.0.0 with: From aecb666523782b554b786e6993915a92d265cb85 Mon Sep 17 00:00:00 2001 From: David Upton Date: Mon, 20 May 2024 16:31:20 -0400 Subject: [PATCH 02/17] DIG-2681 Adjust excludes --- .github/sanitize/publish-excludes.txt | 4 ++-- .github/workflows/D10-GenerateRelease.yml | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/sanitize/publish-excludes.txt b/.github/sanitize/publish-excludes.txt index b93cbb056a..da5deffcbc 100644 --- a/.github/sanitize/publish-excludes.txt +++ b/.github/sanitize/publish-excludes.txt @@ -2,8 +2,8 @@ # Target files known to have sensitive information in them. # This section can be added as new risks are identified. ############################################################ -**/*/bos_*.settings -**/*/node_*.settings +**/*/bos_*.settings.yml +**/*/node_*.settings.yml ############################################################ # Files which shouldn't be included, but probably don't need diff --git a/.github/workflows/D10-GenerateRelease.yml b/.github/workflows/D10-GenerateRelease.yml index 54c98a4158..6cde9e03ed 100644 --- a/.github/workflows/D10-GenerateRelease.yml +++ b/.github/workflows/D10-GenerateRelease.yml @@ -26,9 +26,8 @@ jobs: URL=${URL/git/${{ secrets.PUBLISH_GITHUB_TOKEN }}} echo "gh repo clone ${{ vars.TEST_REPO }} /public -- --depth 1 --branch ${GITHUB_REF_NAME}" gh repo clone ${{ vars.TEST_REPO }} /public -- --depth=1 --branch=$GITHUB_REF_NAME - cd /public - echo "git remote set-url origin $URL" - git remote set-url origin $URL +# echo "git remote set-url origin $URL" +# git remote set-url origin $URL - name: Checkout this repository if: ${{ vars.TEST_REPO_URL == '' }} From bc15b5f2e9f3fddbb6300cac5bc635ae0d9e5b97 Mon Sep 17 00:00:00 2001 From: David Upton Date: Mon, 20 May 2024 16:46:21 -0400 Subject: [PATCH 03/17] DIG-2681 Adjust includes --- .github/sanitize/publish-excludes.txt | 17 +++++++++++++++++ .github/sanitize/publish-from.txt | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/.github/sanitize/publish-excludes.txt b/.github/sanitize/publish-excludes.txt index da5deffcbc..10796bbf33 100644 --- a/.github/sanitize/publish-excludes.txt +++ b/.github/sanitize/publish-excludes.txt @@ -4,6 +4,16 @@ ############################################################ **/*/bos_*.settings.yml **/*/node_*.settings.yml +docroot/modules/custom/**/*settings.yml +config/default/google_tag.settings.yml +config/default/jsonapi.settings.yml +config/default/jsonapi_extras.settings.yml +config/default/login_security.settings.yml +config/default/r4032login.settings.yml +config/default/salesforce.settings.yml +config/default/seckit.settings.yml +config/default/sophron.settings.yml +docroot/modules/custom/slackposter ############################################################ # Files which shouldn't be included, but probably don't need @@ -14,9 +24,16 @@ docroot/sites/default/settings docroot/core docroot/libraries +docroot/sites/all + +# Remove any files +docroot/sites/default/files/private +docroot/sites/default/files/pdf_templates +docroot/sites/default/files/manifest.txt # Remove any Core and Contributed modules docroot/modules/contributed +docroot/themes/contributed # Remove all folders not in the root drush diff --git a/.github/sanitize/publish-from.txt b/.github/sanitize/publish-from.txt index 2a15145c77..7638b41b79 100644 --- a/.github/sanitize/publish-from.txt +++ b/.github/sanitize/publish-from.txt @@ -9,3 +9,12 @@ docroot/modules/custom ############################################################ composer.json composer.lock +LICENSE.md +README.md +############################################################ +# Drupal needs these. +############################################################ +docroot/index.php +docroot/autoload.php +docroot/robots.txt +docroot/update.php From 07ac5c0a9d4abbdf93a08e15899b980eb8f491aa Mon Sep 17 00:00:00 2001 From: David Upton Date: Tue, 21 May 2024 15:42:53 -0400 Subject: [PATCH 04/17] DIG-4405 Fix Project Goals in timeline --- .../modules/node_buildinghousing/node_buildinghousing.module | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docroot/modules/custom/bos_content/modules/node_buildinghousing/node_buildinghousing.module b/docroot/modules/custom/bos_content/modules/node_buildinghousing/node_buildinghousing.module index c11228e472..4f7cc2c08b 100644 --- a/docroot/modules/custom/bos_content/modules/node_buildinghousing/node_buildinghousing.module +++ b/docroot/modules/custom/bos_content/modules/node_buildinghousing/node_buildinghousing.module @@ -329,7 +329,8 @@ function node_buildinghousing_preprocess_field(&$variables) { break; - case 'body': + case 'narrative': +// case 'body': $webUpdate = BuildingHousingUtils::getWebUpdate($project); if (!empty($webUpdate) && $webUpdateGoalText = $webUpdate->get('body')->value) { From cecd425b428fcbacc8cf98b64833f8669d2b8240 Mon Sep 17 00:00:00 2001 From: David Upton Date: Tue, 21 May 2024 19:37:04 -0400 Subject: [PATCH 05/17] DIG-4405: Project Summaries fail to show --- .../node_buildinghousing.module | 26 ++++++++++++++----- .../src/BuildingHousingUtils.php | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/docroot/modules/custom/bos_content/modules/node_buildinghousing/node_buildinghousing.module b/docroot/modules/custom/bos_content/modules/node_buildinghousing/node_buildinghousing.module index 4f7cc2c08b..be0a94cf6f 100644 --- a/docroot/modules/custom/bos_content/modules/node_buildinghousing/node_buildinghousing.module +++ b/docroot/modules/custom/bos_content/modules/node_buildinghousing/node_buildinghousing.module @@ -241,7 +241,13 @@ function node_buildinghousing_entity_presave(EntityInterface $entity) { switch ($entity->getType()) { case 'bh_project': $bhUtils->setPublicStage($entity); - // $streetViewPhoto = $bhUtils->setStreetViewPhoto($entity); + // DIG-4405: Adds a default value for the body when its empty. This + // forces the body to have a value and therefore exist in the fields + // when preprocessing. We can then either ignore it (when default) or + // overwrite with the value from the bh_update (if any). + if (empty($entity->get("body")->value)) { + $entity->set("body", "default"); + } break; case 'bh_update': @@ -279,7 +285,6 @@ function node_buildinghousing_preprocess_field(&$variables) { if ($variables['element']['#bundle'] == 'bh_project') { $fieldName = $variables['field_name'] ?? NULL; $project = $variables['element']['#object'] ?? NULL; - $projectType = _node_buildinghousing_get_computed_project_type($project)['label'] ?? NULL; $hidden = FALSE; switch ($fieldName) { @@ -288,9 +293,11 @@ function node_buildinghousing_preprocess_field(&$variables) { case 'field_bh_units_to_own': case 'field_bh_units_affordable': case 'field_bh_units_total': + $projectType = _node_buildinghousing_get_computed_project_type($project)['label'] ?? NULL; if ($projectType != 'Housing') { $hidden = TRUE; } + case 'field_bh_property_size': $value = $variables['items'][0]['content']['#markup'] ?? NULL; @@ -329,12 +336,17 @@ function node_buildinghousing_preprocess_field(&$variables) { break; - case 'narrative': -// case 'body': + case 'body': + if ($project->get("body")->value == "default") { + // DIG-4405: Initially we want to supress this default entry ... + $hidden = TRUE; + } $webUpdate = BuildingHousingUtils::getWebUpdate($project); - - if (!empty($webUpdate) && $webUpdateGoalText = $webUpdate->get('body')->value) { - $variables["items"][0]["content"]["#text"] = $webUpdateGoalText ?? $variables["items"][0]["content"]["#text"]; + if (!empty($webUpdate) && !empty($webUpdate->get('body')->value)) { + // DIG-4405: ... but if there is a web update, we want to show it. + $hidden = FALSE; + $variables["items"][0]["content"]["#text"] = $webUpdate->get('body')->value; + $variables["items"][0]["content"]["#format"] = "filtered_html"; } break; diff --git a/docroot/modules/custom/bos_content/modules/node_buildinghousing/src/BuildingHousingUtils.php b/docroot/modules/custom/bos_content/modules/node_buildinghousing/src/BuildingHousingUtils.php index 44f6d4fd51..9c0fb985a7 100644 --- a/docroot/modules/custom/bos_content/modules/node_buildinghousing/src/BuildingHousingUtils.php +++ b/docroot/modules/custom/bos_content/modules/node_buildinghousing/src/BuildingHousingUtils.php @@ -162,7 +162,7 @@ public function setProjectWebLink(EntityInterface &$entity) { ->getUrl() ->setAbsolute(FALSE) ->toString() ?? NULL; - $entity->set('field_bh_project_web_link', 'https://www.boston.gov/' . $projectWebLink); + $entity->set('field_bh_project_web_link', 'https://www.boston.gov' . $projectWebLink); return $projectWebLink; } From 0985415abc445893d25767125a788ce9d4a8efd8 Mon Sep 17 00:00:00 2001 From: David Upton Date: Tue, 21 May 2024 23:54:46 -0400 Subject: [PATCH 06/17] DIG-4405: Adds default body on entity load --- .../node_buildinghousing.services.yml | 6 ++ .../BhEntityEventSubscriber.php | 57 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 docroot/modules/custom/bos_content/modules/node_buildinghousing/src/EventSubscriber/BhEntityEventSubscriber.php diff --git a/docroot/modules/custom/bos_content/modules/node_buildinghousing/node_buildinghousing.services.yml b/docroot/modules/custom/bos_content/modules/node_buildinghousing/node_buildinghousing.services.yml index 725ad591e7..5f2fcd27a2 100644 --- a/docroot/modules/custom/bos_content/modules/node_buildinghousing/node_buildinghousing.services.yml +++ b/docroot/modules/custom/bos_content/modules/node_buildinghousing/node_buildinghousing.services.yml @@ -4,3 +4,9 @@ services: arguments: [] tags: - { name: event_subscriber } + + node_buildinghousing.entity_load: + class: Drupal\node_buildinghousing\EventSubscriber\BhEntityEventSubscriber + arguments: [] + tags: + - { name: event_subscriber } diff --git a/docroot/modules/custom/bos_content/modules/node_buildinghousing/src/EventSubscriber/BhEntityEventSubscriber.php b/docroot/modules/custom/bos_content/modules/node_buildinghousing/src/EventSubscriber/BhEntityEventSubscriber.php new file mode 100644 index 0000000000..d969c74b10 --- /dev/null +++ b/docroot/modules/custom/bos_content/modules/node_buildinghousing/src/EventSubscriber/BhEntityEventSubscriber.php @@ -0,0 +1,57 @@ + 'ProjectLoad', + ]; + } + + /** + * @param BosCoreEntityEvent $event + * + * @return BosCoreEntityEvent + */ + public function ProjectLoad(BosCoreEntityEvent $event): BosCoreEntityEvent { + /** + * @var \Drupal\node\Entity\Node $entity + */ + $entity = $event->getEntity(); + + if ($entity->bundle() == "bh_project") { + // DIG-4405: Adds a default value for the body when its empty. This + // forces the body to have a value and therefore exist in the fields + // when preprocessing. We can then either ignore it (when default) or + // overwrite with the value from the bh_update (if any). + $urlparts = explode("/", \Drupal::request()->getRequestUri()); + $final = array_pop($urlparts); + if ($final != "edit" && empty($entity->get("body")->value)) { + // Do not set the default value if we are editing the node. + $entity->set("body", "default"); + } + } + + return $event; + } + +} From 4df6a7e79db5b538f907f392b8c736b6fe1f133c Mon Sep 17 00:00:00 2001 From: David Upton Date: Wed, 22 May 2024 14:32:28 -0400 Subject: [PATCH 07/17] DIG-2681 Separate publish and release notes --- .github/sanitize/publish-excludes.txt | 2 +- .github/sanitize/publish-from.txt | 7 - .../workflows/D10-GeneratePrivateRelease.yml | 86 +++++++++ .../workflows/D10-GeneratePublicRelease.yml | 96 ++++++++++ .github/workflows/D10-GenerateRelease.yml | 102 ---------- .github/workflows/D10-Publish.yml | 179 ++++++++++++++++++ 6 files changed, 362 insertions(+), 110 deletions(-) create mode 100644 .github/workflows/D10-GeneratePrivateRelease.yml create mode 100644 .github/workflows/D10-GeneratePublicRelease.yml delete mode 100644 .github/workflows/D10-GenerateRelease.yml create mode 100644 .github/workflows/D10-Publish.yml diff --git a/.github/sanitize/publish-excludes.txt b/.github/sanitize/publish-excludes.txt index 10796bbf33..8a5daff993 100644 --- a/.github/sanitize/publish-excludes.txt +++ b/.github/sanitize/publish-excludes.txt @@ -61,4 +61,4 @@ config/travis .lando.yml .lando.yml.linux RELEASE.md -**/*/.gitignore +**/.gitignore diff --git a/.github/sanitize/publish-from.txt b/.github/sanitize/publish-from.txt index 7638b41b79..898a2f32c9 100644 --- a/.github/sanitize/publish-from.txt +++ b/.github/sanitize/publish-from.txt @@ -11,10 +11,3 @@ composer.json composer.lock LICENSE.md README.md -############################################################ -# Drupal needs these. -############################################################ -docroot/index.php -docroot/autoload.php -docroot/robots.txt -docroot/update.php diff --git a/.github/workflows/D10-GeneratePrivateRelease.yml b/.github/workflows/D10-GeneratePrivateRelease.yml new file mode 100644 index 0000000000..12238710e1 --- /dev/null +++ b/.github/workflows/D10-GeneratePrivateRelease.yml @@ -0,0 +1,86 @@ +# @file: D10-GeneratePrivateRelease.yml +# This Action cascades from D10-Publish.yml action. +# This Action checks out the current branch (production) Tags the branch and +# publishes a templated release notes file. + +# Attached resources: +# - GitHub SECRETS: +# -> local: PUBLISH_GITHUB_TOKEN -> SSH key used to connect to Acquia GitLab for remote git operations +# -> global: SLACK_DOIT_WEBHOOK_URL -> Webhook URL for posting messages to slack +# - GitHub VARIABLES: +# -> local.SLACK_MONITORING_CHANNEL -> Channel for failure notices +# -> local.DEBUG -> Control flag to denote in debug mode (output extra info) +# -> local.DRY_RUN -> Stops changes being passed back to GitHub +# -> local.LAST_TAG -> Records The previous tag used to tag the private repo +# -> local.THIS_TAG -> Records The tag used to tag the private repo for this publish +# -> local.THIS_RELEASE -> Records the release number for this publish +# -> local.THIS_TITLE -> Records the Pull Request title +# -> local.THIS_BODY -> Records the Pull Request body text + +name: "Generate Private Release Notes" +on: + workflow_dispatch: + workflow_run: + types: + - completed + workflows: [Publish to Public Repo] + branches: [production] + +env: + GH_TOKEN: ${{ secrets.PUBLISH_GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.PUBLISH_GITHUB_TOKEN }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DOIT_WEBHOOK_URL }} # for slack + +jobs: + MakeRelease: + # installed software: https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + + # Checkout this (private) repo, set remote correctly. + - name: Checkout this repository + uses: actions/checkout@v4 + with: + path: public + depth: 5 + + # Create the GitHub private repo Release Note. + - name: Generate Release Note + if: ${{ vars.DRY_RUN == 0 }} + env: + TITLE: ${{ vars.THIS_TITLE }} + TICKETS: ${{ vars.THIS_BODY }} + TAG: ${{ vars.THIS_TAG }} + RELEASE_NOTES: "[PM to complete]" + RELEASE_NUMBER: ${{ vars.THIS_RELEASE }} + WORKING_FILE: "public/CHANGELOG.md" + DRAFT: 0 # 1 = ReleaseNote is draft - else is published + run: | + cd public + printf "## ${{ env.TITLE }} + ### Release By + ${{ github.author }} + ### Pull Request By + ${{ github.triggering_author }} + ### Related Jira tickets + ${{ env.TICKETS }} + ### Acquia tags + ${{ env.TAG }}" > ${{ env.WORKING_FILE }} + options="--latest --generate-notes" + options="$options --notes-start-tag ${{ vars.LAST_TAG }}" + options="$options --notes-file ${{ env.WORKING_FILE }}" + options="$options --title ${{ env.RELEASE_NUMBER }}" + [ ${{ env.DRAFT }} == 1 ] && options="--draft $options" + [ ${{ vars.DRY_RUN }} == 0 ] && gh release create ${{ env.ACQUIA_TAG }} $options + + - name: Post to Slack - failure + uses: act10ns/slack@v2.0.0 + if: ${{ failure() }} + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: ${{ vars.SLACK_MONITORING_CHANNEL }} + message: There were issues publishing release notes for the PRIVATE repository {{workflowRunUrl}} diff --git a/.github/workflows/D10-GeneratePublicRelease.yml b/.github/workflows/D10-GeneratePublicRelease.yml new file mode 100644 index 0000000000..4f0186d399 --- /dev/null +++ b/.github/workflows/D10-GeneratePublicRelease.yml @@ -0,0 +1,96 @@ +# @file: D10-GeneratePublicRelease.yml +# This Action cascades from D10-Publish.yml action. +# This Action checks out the desired branch of the public repo, Tags the branch +# and drafts a templated release notes file. + +# Attached resources: +# - GitHub SECRETS: +# -> local: PUBLISH_GITHUB_TOKEN -> SSH key used to connect to Acquia GitLab for remote git operations +# -> local: PUBLIC_REPO_TARGET -> URL of the public repo to be updated +# -> local: PUBLIC_REPO_TARGET_BRANCH -> Branch of the public repo to be updated +# -> global: SLACK_DOIT_WEBHOOK_URL -> Webhook URL for posting messages to slack +# - GitHub VARIABLES: +# -> local.SLACK_MONITORING_CHANNEL -> Channel for failure notices +# -> local.DRY_RUN -> Stops changes being passed back to GitHub +# -> local.LAST_TAG -> Records The previous tag used to tag the private repo +# -> local.THIS_TAG -> Records The tag used to tag the private repo for this publish +# -> local.THIS_RELEASE -> Records the release number for this publish +# -> local.THIS_TITLE -> Records the Pull Request title +# -> local.THIS_BODY -> Records the Pull Request body text + +name: "Generate Private Release Notes" +on: + workflow_dispatch: + workflow_run: + types: + - completed + workflows: [Publish to Public Repo] + branches: [production] +env: + GH_TOKEN: ${{ secrets.PUBLISH_GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.PUBLISH_GITHUB_TOKEN }} + DEV_EMAIL: "digital-dev@boston.gov" + USER: "City of Boston Deploy Pipeline" + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DOIT_WEBHOOK_URL }} # for slack + +jobs: + MakeRelease: + # installed software: https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + + # Checkout THE public repo, set remote correctly. + - name: Checkout Public repository + id: Checkout-Public-Repo + run: | + URL=${{ secrets.PUBLIC_REPO_TARGET }} + echo "gh repo clone $URL publish -- --depth 10 --branch ${{ secrets.PUBLIC_REPO_TARGET_BRANCH }}" + gh repo clone $URL publish -- --depth=10 --branch=${{ secrets.PUBLIC_REPO_TARGET_BRANCH }} + cd publish + git fetch origin ${{ secrets.PUBLIC_REPO_TARGET_BRANCH }} + git reset --hard FETCH_HEAD + + # Tag the branch and push to remote. + - name: Tag the branch + run: | + cd publish + git config --global user.email "${{ env.DEV_EMAIL }}" + git config --global user.name "${{ env.USER }}" + git tag -a "${{ vars.THIS_TAG }}" -m "${{ env.RELEASE_NUMBER }}" + [ ${{ vars.DRY_RUN }} == 0 ] && git push origin ${{ vars.THIS_TAG }} + + # Create the GitHub PUBLIC repo Release Note. + - name: Generate Release Notes + if: ${{ vars.DRY_RUN == 0 }} + env: + TITLE: ${{ vars.THIS_TITLE }} + TICKETS: ${{ vars.THIS_BODY }} + RELEASE_NOTES: "[PM to complete]" + RELEASE_NUMBER: ${{ vars.THIS_RELEASE }} + WORKING_FILE: "public/CHANGELOG.md" + DRAFT: 1 # 1 = ReleaseNote is draft - else is published + run: | + cd public + printf "## ${{ env.TITLE }} + ### Release By + ${{ github.author }} + ### Release Notes + ${{ env.RELEASE_NOTES }}" > ${{ env.WORKING_FILE }} + options="--latest --generate-notes" + options="$options --notes-start-tag ${{ vars.LAST_TAG }}" + options="$options --notes-file ${{ env.WORKING_FILE }}" + options="$options --title ${{ env.RELEASE_NUMBER }}" + [ ${{ env.DRAFT }} == 1 ] && options="--draft $options" + [ ${{ vars.DRY_RUN }} == 0 ] && gh release create ${{ env.ACQUIA_TAG }} $options + + - name: Post to Slack - failure + uses: act10ns/slack@v2.0.0 + if: ${{ failure() }} + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: ${{ vars.SLACK_MONITORING_CHANNEL }} + message: There were issues generating draft release notes for the PUBLIC repo {{workflowRunUrl}} diff --git a/.github/workflows/D10-GenerateRelease.yml b/.github/workflows/D10-GenerateRelease.yml deleted file mode 100644 index 6cde9e03ed..0000000000 --- a/.github/workflows/D10-GenerateRelease.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: "Generate Release Notes" -on: - workflow_dispatch: - push: - branches: # we can add branches to this list which will deploy code to Acquia GitLab as we push code to those branches. - - production - -env: - GH_TOKEN: ${{ secrets.PUBLISH_GITHUB_TOKEN }} - GITHUB_TOKEN: ${{ secrets.PUBLISH_GITHUB_TOKEN }} - -jobs: - MakeRelease: - # installed software: https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md - runs-on: ubuntu-latest - defaults: - run: - shell: bash - steps: - - # Checkout this repo, set remote correctly. - - name: Checkout a repository - if: ${{ vars.TEST_REPO_URL != '' }} - run: | - URL=${{ vars.TEST_REPO_URL }} - URL=${URL/git/${{ secrets.PUBLISH_GITHUB_TOKEN }}} - echo "gh repo clone ${{ vars.TEST_REPO }} /public -- --depth 1 --branch ${GITHUB_REF_NAME}" - gh repo clone ${{ vars.TEST_REPO }} /public -- --depth=1 --branch=$GITHUB_REF_NAME -# echo "git remote set-url origin $URL" -# git remote set-url origin $URL - - - name: Checkout this repository - if: ${{ vars.TEST_REPO_URL == '' }} - uses: actions/checkout@v4 - with: - path: /public - depth: 5 - - # Create some variables for later use. - # Try to make sure our tags align with Acquia tags. - - name: Set environment variables - run: | - cd /public - echo 'pr=$(gh pr list -s merged --head ${{ github.ref_name }} -L 1 ' - pr=$(gh pr list -s merged --head ${{ github.ref_name }} -L 1 | awk '{print $1}' | xargs gh pr view --json title,body) || pr='{"title":"Unknown PR","body":"Cannot find a PR for ${{ github.ref_name }}. "}' - echo "pr=${pr}" >> "${GITHUB_ENV}" - [[ ${{ vars.DEBUG == 1 }} ]] && printf "PR Notes:\n${pr}\n" - count=0 - ACQUIA_TAG=$(date +tags/%Y-%m-%d) - while [[ $(git tag --list | grep $ACQUIA_TAG) ]]; do - ACQUIA_TAG=$(date +tags/%Y-%m-%d).$count - count=$(($count+1)) - ok=$(git tag --list | grep $ACQUIA_TAG) || break - [[ $count -gt 10 ]] && exit 100 - done - echo "ACQUIA_TAG=$ACQUIA_TAG" >> "${GITHUB_ENV}" - echo "RELEASE_NUMBER=v10_$(date +%Y)_${{ vars.COUNT }}" >> "${GITHUB_ENV}" - - # Tag the branch and push to remote. - - name: Tag the branch - run: | - cd /public - git config --global user.email "digital-dev@boston.gov" - git config --global user.name "Github Action" - [ ${{ vars.DRY_RUN }} == 0 ] && \ - git tag -a "${{ env.ACQUIA_TAG }}" -m "${{ env.RELEASE_NUMBER }}" && \ - git push origin ${{ env.ACQUIA_TAG }} || echo "Tag Exists" - exit 1 - - # Create the GitHub PUBLIC repo Release Note. - - name: Generate Release Notes - env: - TITLE: ${{ fromJSON(env.pr).title }} - TICKETS: ${{ fromJSON(env.pr).body }} - RELEASE_NOTES: "[PM to complete]" - WORKING_FILE: "/public/CHANGELOG.md" - DRAFT: 1 # 1 = ReleaseNote is draft - else is published - run: | - cd /public - printf "## ${{ env.TITLE }} - ### Release By - ${{ github.author }} - ### Pull Request By - ${{ github.triggering_author }} - ### Release Notes - ${{ env.RELEASE_NOTES }} - ### Related Jira tickets - ${{ env.TICKETS }} - ### Acquia tags - ${{ env.ACQUIA_TAG }}" > ${{ env.WORKING_FILE }} - options="--latest --generate-notes" - options="$options --notes-start-tag ${{ vars.LAST_TAG }}" - options="$options --notes-file ${{ env.WORKING_FILE }}" - options="$options --title ${{ env.RELEASE_NUMBER }}" - [ ${{ env.DRAFT }} == 1 ] && options="--draft $options" - [ ${{ vars.DRY_RUN }} == 0 ] && gh release create ${{ env.ACQUIA_TAG }} $options - - - name: Save some variables for future runs. - run: | - cd /public - gh variable set COUNT --body $(( ${{ vars.COUNT }}+1 )) - gh variable set LAST_TAG --body ${{ env.ACQUIA_TAG }} diff --git a/.github/workflows/D10-Publish.yml b/.github/workflows/D10-Publish.yml new file mode 100644 index 0000000000..97dde2a44c --- /dev/null +++ b/.github/workflows/D10-Publish.yml @@ -0,0 +1,179 @@ +# @file: D10-Publish.yml +# This Action clones the current private repo, sanitizes it (removes potentially +# secrets-containing files) and then commits resultant files to the Public repo. +# - This Action is fired when the production branch has code pushed to it, +# this is typically when: +# 1. a PR to the production branch is committed, or +# 2. a commit is pushed and merged directly into the production branch, or +# 3. (maybe) any other activity which alters the code at the HEAD of the +# production branch or moves the HEAD of the branch. + +# Several actions to make Release Notes and Tags cascade on completion of this +# workflow. +# - d10-GeneratePrivateRelease.yml +# - d10-GeneratePublicRelease.yml + +# Attached resources: +# - GitHub SECRETS: +# -> local: PUBLIC_REPO_TARGET -> The public repoistory fmt CityOfBoston/xxxx +# -> global.PUBLIC_REPO_TARGET_BRANCH -> Branch to push to in the +# -> global.PUBLISH_GITHUB_TOKEN -> GitHub token used for gh cli and auth for private repos +# -> global: SLACK_DOIT_WEBHOOK_URL -> Webhook URL for posting messages to slack +# - GitHub VARIABLES: +# => INTERNAL VARS +# -> local.SLACK_MONITORING_CHANNEL -> Channel for failure notices +# -> local.DEBUG -> Control flag to denote in debug mode (output extra info) +# -> local.DRY_RUN -> Stops changes being passed back to GitHub +# -> local.COUNT -> A counter used to create unique sequential RELEASE numbers +# => VARS SHARED WITH OUTHER WORKFLOWS +# -> local.LAST_TAG -> Records The previous tag used to tag the private repo +# -> local.THIS_TAG -> Records The tag used to tag the private repo for this publish +# -> local.THIS_RELEASE -> Records the release number for this publish +# -> local.THIS_TITLE -> Records the Pull Request title +# -> local.THIS_BODY -> Records the Pull Request body text + +name: "Publish to Public Repo" +on: + workflow_dispatch: + pull_request: + types: + - closed + branches: + - production + +env: + GH_TOKEN: ${{ secrets.PUBLISH_GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.PUBLISH_GITHUB_TOKEN }} + DEV_EMAIL: "digital-dev@boston.gov" + PR_USER: ${{ github.event.pull_request.merged_by.name }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DOIT_WEBHOOK_URL }} # for slack + +jobs: + Publish: + + # Only run is the PR has been merged and closed (not just closed) or DEBUG. + if: github.event.pull_request.merged == true || vars.DEBUG == 1 + + # installed software: https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the + # added or changed files to the repository. + contents: write + + steps: + + # Checkout this (private) repository into local "private" folder. + - name: Checkout (this) Private repository into local "private" folder. + id: Checkout-Private-Repo + uses: actions/checkout@v4 + with: + path: private + fetch-depth: 0 # 0 = all - otherwise, will likely fail to push tags to dest repo + + - name: Debug event context + if: ${{ vars.DEBUG == 1 }} + env: + EVENT_CONTEXT: ${{ toJSON(github.event) }} + run: | + echo $EVENT_CONTEXT + + # Create and save some variables for use in the cascading actions. + # Set them here, so they can be simply read by the other actions, and we + # can (try to) make sure our tags align with Acquia tags. + - name: Set environment variables + run: | + cd private + count=0 + ACQUIA_TAG=$(date +tags/%Y-%m-%d) + while [[ $(git tag --list | grep $ACQUIA_TAG) ]]; do + ACQUIA_TAG=$(date +tags/%Y-%m-%d).$count + count=$(($count+1)) + ok=$(git tag --list | grep $ACQUIA_TAG) || break + [[ $count -gt 10 ]] && exit 100 + done + RELEASE_NUMBER=v10_$(date +%Y)_${{ vars.COUNT }} + [ -n "${{ github.event.pull_request.title }}" ] && TITLE="${{ github.event.pull_request.title }}" || TITLE="Boston.gov Update" + [ -n "${{ github.event.pull_request.body }}" ] && BODY="${{ github.event.pull_request.body }}" || BODY="PR committed and merged." + gh variable set COUNT --body $(( ${{ vars.COUNT }}+1 )) + gh variable set LAST_TAG --body "${{ vars.THIS_TAG }}" + gh variable set THIS_TAG --body "$ACQUIA_TAG" + gh variable set THIS_RELEASE --body "$RELEASE_NUMBER" + gh variable set THIS_TITLE --body "$TITLE" + gh variable set THIS_BODY --body "$BODY" + + - name: Checkout Public repository + id: Checkout-Public-Repo + run: | + URL=${{ secrets.PUBLIC_REPO_TARGET }} + echo "gh repo clone $URL publish -- --depth 10 --branch ${{ secrets.PUBLIC_REPO_TARGET_BRANCH }}" + gh repo clone $URL publish -- --depth=10 --branch=${{ secrets.PUBLIC_REPO_TARGET_BRANCH }} + cd publish + git fetch origin ${{ secrets.PUBLIC_REPO_TARGET_BRANCH }} + git reset --hard FETCH_HEAD + + # Sanitize the code in the local "private" folder + - name: Sanitize Repo + id: Sanitize-Codebase + env: + publish_from_file: ${{ github.workspace }}/private/.github/sanitize/publish-from.txt + publish_excludes_file: ${{ github.workspace }}/private/.github/sanitize/publish-excludes.txt + run: | + err="" + cd private + rsync -rlDWz --max-size=10m --files-from=${publish_from_file} --exclude-from=${publish_excludes_file} --delete-after . ../publish && echo "Copied updated codebase" || err="Error copying updated codebase" + [[ "$( git status --porcelain --untracked-files=no --ignored=no )" == "" ]] && echo "changes=0" >> "$GITHUB_OUTPUT" || echo "changes=1" >> "$GITHUB_OUTPUT" + if [[ "$err" != "" ]]; then + echo "::error file=publish.yml,title=Error,line=139::$err" + exit 1 + fi + + # Tag and push (updated local) private repository + # Tag the branch and push to remote. + - name: Tag the Private Repo branch + run: | + cd private + git config --global user.email "${{ env.DEV_EMAIL }}" + if [[ -z "${{ env.PR_USER }}" ]]; then + git config --global user.name "Guthub Publish Action" + else + git config --global user.name "${{ env.PR_USER }}" + fi + git tag -a "${{ vars.THIS_TAG }}" -m "${{ vars.THIS_RELEASE }}" + [ ${{ vars.DRY_RUN }} == 0 ] && git push origin ${{ vars.THIS_TAG }} || echo "Tagging DRY_RUN mode" + + # Commit and push (updated local) public repository + - uses: stefanzweifel/git-auto-commit-action@v5 + if: ${{ vars.DRY_RUN == 0 }} + id: Commit-Codebase + with: + commit_message: ${{ vars.THIS_TITLE }} + branch: ${{ secrets.PUBLIC_REPO_TARGET_BRANCH }} + commit_options: '--no-verify --signoff' + repository: publish + commit_user_name: Github Actions Publisher + commit_user_email: ${{ env.DEV_EMAIL }} + tagging_message: '${{ vars.THIS_TAG }}' + status_options: '--untracked-files=no' + add_options: '-u' + push_options: '--force' + skip_dirty_check: true + skip_fetch: true + skip_checkout: true + disable_globbing: true + create_branch: true +# commit_author: ${{ github.event.pull_request.merged_by.name }} <${{ env.DEV_EMAIL }}> + + - name: Post to Slack - failure + uses: act10ns/slack@v2.0.0 + if: ${{ failure() }} + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: ${{ vars.SLACK_MONITORING_CHANNEL }} + message: There were issues publishing to the Public Repo {{workflowRunUrl}} From a0d73eb3ac9f2382251ed1481333770c2c36b662 Mon Sep 17 00:00:00 2001 From: David Upton Date: Wed, 22 May 2024 15:09:58 -0400 Subject: [PATCH 08/17] DIG-2681 refactoring and commenting --- .github/workflows/D10-Deploy.yml | 34 +++---- .../workflows/D10-GeneratePublicRelease.yml | 4 +- .github/workflows/D10-NotifyRelease.yml | 8 +- .github/workflows/percy_snapshot.yml | 92 +++++++++++++++++++ .github/workflows/percy_snapshot_static.yml | 33 ------- .../workflows/percy_snapshot_static_stage.yml | 33 ------- 6 files changed, 119 insertions(+), 85 deletions(-) create mode 100644 .github/workflows/percy_snapshot.yml delete mode 100644 .github/workflows/percy_snapshot_static.yml delete mode 100644 .github/workflows/percy_snapshot_static_stage.yml diff --git a/.github/workflows/D10-Deploy.yml b/.github/workflows/D10-Deploy.yml index 1fa1d62113..30ab4ed863 100644 --- a/.github/workflows/D10-Deploy.yml +++ b/.github/workflows/D10-Deploy.yml @@ -15,10 +15,12 @@ # -> local: SSH_GITHUB_KEY -> SSH key used to connect to GitHub for remote git operations # -> local: ACQUIA_SSH_KEY -> SSH key used to connect to Acquia GitLab for remote git operations # -> local: ACQUIA_REMOTE_REPO_URL -> URL for the Acquia GitLab repository -# -> local: PRIVATE_REPO_URL -> The private repo to merge into the tracked repo +# -> local: SETTINGS_REPO_URL -> The private repo to merge into the tracked repo # -> global: SLACK_DOIT_WEBHOOK_URL -> Webhook URL for posting messages to slack # - GitHub VARIABLES: -# -> local: SLACK_DRUPAL_CHANNEL -> Channel to post devops messages into +# -> local: SLACK_MONITORING_CHANNEL -> Channel to post devops messages into +# -> local: DEBUG -> Channel to post devops messages into +# -> local: DRY_RUN -> Channel to post devops messages into name: "Deploy to Acquia" on: @@ -52,7 +54,7 @@ jobs: channel: ${{ vars.SLACK_MONITORING_CHANNEL }} - name: Output some debugging info - if: ${{ vars.DEPLOY_DEBUG == 1 }} + if: ${{ vars.DEBUG == 1 }} run: | export pwd @@ -66,7 +68,7 @@ jobs: # More debugging (full PHP configuration) - name: Output more debugging info - if: ${{ vars.DEPLOY_DEBUG == 1 }} + if: ${{ vars.DEBUG == 1 }} run: | php -i @@ -84,7 +86,7 @@ jobs: - name: Checkout the private repository uses: actions/checkout@v4 with: - repository: ${{ secrets.PRIVATE_REPO_URL }} + repository: ${{ secrets.SETTINGS_REPO_URL }} ssh-key: ${{ secrets.SSH_GITHUB_KEY }} ref: develop persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token @@ -130,7 +132,7 @@ jobs: working_dir: candidate - name: Directory listings for completed build - if: ${{ vars.DEPLOY_DEBUG == 1 }} + if: ${{ vars.DEBUG == 1 }} run: | echo "Directory Tree for $(pwd)/candidate" && du ./candidate # echo "Directory Listing for $(pwd)/candidate" && ls -lAh --group-directories-first candidate @@ -145,7 +147,7 @@ jobs: run: | acquia_ssh_key_path="${HOME}/.ssh" acquia_ssh_key_file="${HOME}/.ssh/id_rsa" - [[ ${{ vars.DEPLOY_DEBUG }} == 1 ]] && echo "ssh-key-file: $acquia_ssh_key_file" && echo "ssh-key-path: $acquia_ssh_key_path" + [[ ${{ vars.DEBUG }} == 1 ]] && echo "ssh-key-file: $acquia_ssh_key_file" && echo "ssh-key-path: $acquia_ssh_key_path" mkdir -p $acquia_ssh_key_path echo "${{ secrets.ACQUIA_SSH_KEY }}" > "$acquia_ssh_key_file" chmod 600 $acquia_ssh_key_file @@ -173,7 +175,7 @@ jobs: else git checkout --no-progress --force -B ${{ env.ACQUIA_BRANCH }} || err="$err: Problem creating a new branch" fi - if [[ ${{ vars.DEPLOY_DEBUG }} == 1 ]]; then + if [[ ${{ vars.DEBUG }} == 1 ]]; then [[ $newbranch == 0 ]] && git log -1 --format='%H' echo "Directory Listing for $(pwd)" && ls -lAh fi @@ -203,13 +205,13 @@ jobs: rsync -rlDWz --delete-after --files-from=${deploy_from_file} --exclude-from=${deploy_excludes_file} candidate remote printf "docroot/modules/**/.git\ndocroot/libraries/**/.git\n" > remote/.gitignore cd candidate && mergemsg=$(git log -1 --oneline ${{ github.sha }}) && cd ../ - $(grep -qi 'hotfix' <<< '${mergemsg}') && echo '[NOTICE] HotFix detected' || ([[ ${{ vars.DEPLOY_DEBUG }} == 1 ]] && echo "mergemsg=${mergemsg}") + $(grep -qi 'hotfix' <<< '${mergemsg}') && echo '[NOTICE] HotFix detected' || ([[ ${{ vars.DEBUG }} == 1 ]] && echo "mergemsg=${mergemsg}") $(grep -qi 'hotfix' <<< '${mergemsg}') && touch remote/.hotfix || rm -f remote/.hotfix echo "MERGEMSG=$mergemsg" >> "$GITHUB_ENV" echo "SHORTSHA=${GITHUB_SHA::8}...${GITHUB_SHA: -4}" >> "$GITHUB_ENV" - name: Directory listings for finalized candidate - if: ${{ vars.DEPLOY_DEBUG == 1 }} + if: ${{ vars.DEBUG == 1 }} run: | echo "Directory Listing for $(pwd)/remote" && ls -lAh --group-directories-first remote echo "Directory Listing for $(pwd)/remote/docroot" && ls -lAh --group-directories-first remote/docroot @@ -232,23 +234,23 @@ jobs: err="" cd remote git submodule deinit --all || err="$err: Could not de-initialize submodules" - if [[ ${{ vars.DEPLOY_DEBUG }} == 1 ]]; then + if [[ ${{ vars.DEBUG }} == 1 ]]; then echo "Working Tree Status (pre-add&commit):" git status fi git add --all && echo ' ' || err="$err: Failed to add changed files" - [[ ${{ vars.DEPLOY_DEBUG }} == 1 ]] && commitopt="--status" || commitopt="--quiet" + [[ ${{ vars.DEBUG }} == 1 ]] && commitopt="--status" || commitopt="--quiet" res=$(git commit -m '${{ env.commitmsg }}' $commitopt) || err="$err: Problem committing changes" - if [[ ${{ vars.DEPLOY_DEBUG }} == 1 ]]; then + if [[ ${{ vars.DEBUG }} == 1 ]]; then echo "Working Tree Status (post-add&commit):" git status fi pushopts="" - if [[ ${{ vars.DEPLOY_DEBUG }} == 1 ]]; then + if [[ ${{ vars.DEBUG }} == 1 ]]; then echo "Commit results:" && echo $res pushopts="--verbose" fi - if [[ ${{ vars.DEPLOY_DRY_RUN }} == 1 ]]; then + if [[ ${{ vars.DRY_RUN }} == 1 ]]; then pushopts="$pushopts --dry-run" echo "::notice file=deploy.yml,title=DRY-RUN::DRY_RUN envar set. Any commits will not be pushed to Acquia." fi @@ -256,7 +258,7 @@ jobs: echo "changes=1" >> "$GITHUB_OUTPUT" echo "git push --set-upstream acquia ${{ env.ACQUIA_BRANCH }}:${{ env.ACQUIA_BRANCH }} ${pushopts}" git push --set-upstream acquia ${{ env.ACQUIA_BRANCH }}:${{ env.ACQUIA_BRANCH }} ${pushopts} || err="$err: Problem pushing changes to Acquia" - if [[ ${{ vars.DEPLOY_DRY_RUN }} == 0 ]]; then + if [[ ${{ vars.DRY_RUN }} == 0 ]]; then echo "::notice file=deploy.yml,title=Success::Remote/Acquia repository was updated- check Acquia for deploy status." else echo "::notice file=deploy.yml,title=Success::Remote/Acquia repository was not updated because this was a dry-run." diff --git a/.github/workflows/D10-GeneratePublicRelease.yml b/.github/workflows/D10-GeneratePublicRelease.yml index 4f0186d399..ae9b18d709 100644 --- a/.github/workflows/D10-GeneratePublicRelease.yml +++ b/.github/workflows/D10-GeneratePublicRelease.yml @@ -2,7 +2,7 @@ # This Action cascades from D10-Publish.yml action. # This Action checks out the desired branch of the public repo, Tags the branch # and drafts a templated release notes file. - +# # Attached resources: # - GitHub SECRETS: # -> local: PUBLISH_GITHUB_TOKEN -> SSH key used to connect to Acquia GitLab for remote git operations @@ -18,7 +18,7 @@ # -> local.THIS_TITLE -> Records the Pull Request title # -> local.THIS_BODY -> Records the Pull Request body text -name: "Generate Private Release Notes" +name: "Generate Public Release Notes" on: workflow_dispatch: workflow_run: diff --git a/.github/workflows/D10-NotifyRelease.yml b/.github/workflows/D10-NotifyRelease.yml index b54329c9a2..ce6f9bf01c 100644 --- a/.github/workflows/D10-NotifyRelease.yml +++ b/.github/workflows/D10-NotifyRelease.yml @@ -1,4 +1,10 @@ -name: Broadcast Release Notes (slack) +# Attached resources: +# - GitHub SECRETS: +# -> global: SLACK_WEBHOOK_URL -> Webhook URL for posting messages to slack +# - GitHub VARIABLES: +# -> local.SLACK_RELEASE_CHANNEL -> Notify people that release is ready. + +name: Broadcast Release Notes on: release: types: [released] diff --git a/.github/workflows/percy_snapshot.yml b/.github/workflows/percy_snapshot.yml new file mode 100644 index 0000000000..b848920b2c --- /dev/null +++ b/.github/workflows/percy_snapshot.yml @@ -0,0 +1,92 @@ +# @file(yaml) +# == GITHUB ACTION == +# Percy screenshot scripting for Boston.gov +# Workflow monitors master branch and is triggered by a Pull Request. +# The action is triggered before the code reaches the stage environment, so the workflow compares screenshots taken +# from the develop environment. + +# Attached resources: +# - GitHub SECRETS: +# -> local.PERCY_TOKEN_STAGE -> Notify people that release is ready. +# -> local.PERCY_TOKEN -> Notify people that release is ready. + +name: Percy Snapshot Regression Testing + +env: + PERCY_CONFIG: "$GITHUB_WORKSPACE/.github/percy/percy_config.yml" + +on: + workflow_dispatch: + pull_request: + branches: + - master + - production + types: + - opened + - reopened + - synchronize + +jobs: + + percy_stage: + + if: ${{ github.ref_name == 'master' }} + runs-on: ubuntu-latest + + env: + SNAPSHOT_CONFIG: "$GITHUB_WORKSPACE/.github/percy/snapshot_config.yml" + + defaults: + run: + shell: bash + + steps: + - name: checkout percy files + uses: Bhacaz/checkout-files@v2 + with: + files: .github/percy + branch: develop + + - name: Setup Node 16 + uses: actions/setup-node@v3 + with: + node-version: '16' + + - name: Install Percy CLI + run: npm install --save-dev @percy/cli + + - name: Compare Frontend Snapshots + run: | + npx @percy/cli snapshot --config ${{ env.PERCY_CONFIG }} ${{ env.SNAPSHOT_CONFIG }} + env: + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} + + percy_production: + + if: ${{ github.ref_name == 'production' }} + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + + steps: + - name: checkout percy files + uses: Bhacaz/checkout-files@v2 + with: + files: .github/percy + branch: master + + - name: Setup Node 16 + uses: actions/setup-node@v3 + with: + node-version: '16' + + - name: Install Percy CLI + run: npm install --save-dev @percy/cli + + - name: Compare Frontend Snapshots + run: | + npx @percy/cli snapshot --config ${{ env.PERCY_CONFIG }} ${{ env.SNAPSHOT_CONFIG }} + env: + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_STAGE }} diff --git a/.github/workflows/percy_snapshot_static.yml b/.github/workflows/percy_snapshot_static.yml deleted file mode 100644 index 1ca92fd80b..0000000000 --- a/.github/workflows/percy_snapshot_static.yml +++ /dev/null @@ -1,33 +0,0 @@ -# @file(yaml) -# == GITHUB ACTION == -# Percy screenshot scripting for Boston.gov -# Workflow monitors master branch and is triggered by a Pull Request. -# The action is triggered before the code reaches the stage environment, so the workflow compares screenshots taken -# from the develop environment. -name: Boston.gov Percy Snapshot Regression Testing -on: - pull_request: - branches: [ "master" ] - workflow_dispatch: -jobs: - percy_frontend_test: - runs-on: ubuntu-latest - defaults: - run: - shell: bash - steps: - - name: checkout percy files - uses: Bhacaz/checkout-files@v2 - with: - files: .github/percy - branch: develop - - name: Setup Node 16 - uses: actions/setup-node@v3 - with: - node-version: '16' - - name: Install Percy CLI - run: npm install --save-dev @percy/cli - - name: Compare Frontend Snapshots - run: npx @percy/cli snapshot --config "$GITHUB_WORKSPACE/.github/percy/percy_config.yml" "$GITHUB_WORKSPACE/.github/percy/snapshot_config.yml" - env: - PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} diff --git a/.github/workflows/percy_snapshot_static_stage.yml b/.github/workflows/percy_snapshot_static_stage.yml deleted file mode 100644 index 9632088cf6..0000000000 --- a/.github/workflows/percy_snapshot_static_stage.yml +++ /dev/null @@ -1,33 +0,0 @@ -# @file(yaml) -# == GITHUB ACTION == -# Percy screenshot scripting for Boston.gov -# Workflow monitors master branch and is triggered by a Pull Request. -# The action is triggered before the code reaches the stage environment, so the workflow compares screenshots taken -# from the develop environment. -name: Boston.gov Percy Snapshot Regression Testing -on: - pull_request: - branches: [ "production" ] - workflow_dispatch: -jobs: - percy_frontend_test: - runs-on: ubuntu-latest - defaults: - run: - shell: bash - steps: - - name: checkout percy files - uses: Bhacaz/checkout-files@v2 - with: - files: .github/percy - branch: develop - - name: Setup Node 16 - uses: actions/setup-node@v3 - with: - node-version: '16' - - name: Install Percy CLI - run: npm install --save-dev @percy/cli - - name: Compare Frontend Snapshots - run: npx @percy/cli snapshot --config "$GITHUB_WORKSPACE/.github/percy/percy_config.yml" "$GITHUB_WORKSPACE/.github/percy/snapshot_config_stage.yml" - env: - PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_STAGE }} From 91fbbe4782439c6f75989e47294013cb5aefe96d Mon Sep 17 00:00:00 2001 From: David Upton Date: Thu, 23 May 2024 20:41:05 -0400 Subject: [PATCH 09/17] Update percy_snapshot.yml --- .github/workflows/percy_snapshot.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/percy_snapshot.yml b/.github/workflows/percy_snapshot.yml index b848920b2c..da4284e342 100644 --- a/.github/workflows/percy_snapshot.yml +++ b/.github/workflows/percy_snapshot.yml @@ -28,6 +28,27 @@ on: jobs: + debug: + runs-on: ubuntu-latest + if: ${{ vars.DEBUG == 1 }} + + defaults: + run: + shell: bash + + steps: + - name: Debug event context + env: + EVENT_CONTEXT: ${{ toJSON(github.event) }} + run: | + echo $EVENT_CONTEXT + + - name: Debug event context + env: + EVENT_CONTEXT: ${{ toJSON(github) }} + run: | + echo $EVENT_CONTEXT + percy_stage: if: ${{ github.ref_name == 'master' }} From a5e247b715abd23a41df2c5a349c9ccf1b2b5f32 Mon Sep 17 00:00:00 2001 From: David Upton Date: Thu, 23 May 2024 20:48:30 -0400 Subject: [PATCH 10/17] Update percy_snapshot.yml --- .github/workflows/percy_snapshot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/percy_snapshot.yml b/.github/workflows/percy_snapshot.yml index da4284e342..e014297a5c 100644 --- a/.github/workflows/percy_snapshot.yml +++ b/.github/workflows/percy_snapshot.yml @@ -51,7 +51,7 @@ jobs: percy_stage: - if: ${{ github.ref_name == 'master' }} + if: ${{ github.ref == 'master' }} runs-on: ubuntu-latest env: @@ -84,7 +84,7 @@ jobs: percy_production: - if: ${{ github.ref_name == 'production' }} + if: ${{ github.ref == 'production' }} runs-on: ubuntu-latest defaults: From 4bb9e5f919e71c16e12b4a85b8e965594ab0310e Mon Sep 17 00:00:00 2001 From: David Upton Date: Thu, 23 May 2024 22:47:23 -0400 Subject: [PATCH 11/17] Adds GitHub Actions for deployment. --- .github/workflows/percy_snapshot.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/percy_snapshot.yml b/.github/workflows/percy_snapshot.yml index da4284e342..a06f11afaa 100644 --- a/.github/workflows/percy_snapshot.yml +++ b/.github/workflows/percy_snapshot.yml @@ -31,21 +31,25 @@ jobs: debug: runs-on: ubuntu-latest if: ${{ vars.DEBUG == 1 }} - + defaults: run: - shell: bash - + shell: bash + steps: - - name: Debug event context + - name: Debug ENVARS + run: | + export + + - name: Debug github context env: - EVENT_CONTEXT: ${{ toJSON(github.event) }} + GITHUB_CONTEXT: ${{ toJSON(github) }} run: | - echo $EVENT_CONTEXT + echo $GITHUB_CONTEXT - - name: Debug event context + - name: Debug github.event context env: - EVENT_CONTEXT: ${{ toJSON(github) }} + EVENT_CONTEXT: ${{ toJSON(github.event) }} run: | echo $EVENT_CONTEXT From 3fcf1aba79f8238d23760c7ec9b40f3fb2f014c0 Mon Sep 17 00:00:00 2001 From: David Upton Date: Thu, 23 May 2024 22:52:12 -0400 Subject: [PATCH 12/17] Adds GitHub Actions for deployment. --- .github/workflows/percy_snapshot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/percy_snapshot.yml b/.github/workflows/percy_snapshot.yml index 669436ca97..93db58b134 100644 --- a/.github/workflows/percy_snapshot.yml +++ b/.github/workflows/percy_snapshot.yml @@ -55,7 +55,7 @@ jobs: percy_stage: - if: ${{ github.ref == 'master' }} + if: ${{ github.base_ref == 'master' }} runs-on: ubuntu-latest env: @@ -88,7 +88,7 @@ jobs: percy_production: - if: ${{ github.ref == 'production' }} + if: ${{ github.base_ref == 'production' }} runs-on: ubuntu-latest defaults: From dbb01335395b188839f4e7d098b585beb086c3c2 Mon Sep 17 00:00:00 2001 From: David Upton Date: Thu, 23 May 2024 23:43:59 -0400 Subject: [PATCH 13/17] Adds GitHub Actions for deployment. --- .github/workflows/D10-Deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/D10-Deploy.yml b/.github/workflows/D10-Deploy.yml index 30ab4ed863..4700fd2fe4 100644 --- a/.github/workflows/D10-Deploy.yml +++ b/.github/workflows/D10-Deploy.yml @@ -86,7 +86,7 @@ jobs: - name: Checkout the private repository uses: actions/checkout@v4 with: - repository: ${{ secrets.SETTINGS_REPO_URL }} + repository: git@github.com:CityOfBoston/boston.gov-d8-private.git ssh-key: ${{ secrets.SSH_GITHUB_KEY }} ref: develop persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token From 38f263e2fd87bb12a0343023eb4aa998d248b6d8 Mon Sep 17 00:00:00 2001 From: David Upton Date: Thu, 23 May 2024 23:45:45 -0400 Subject: [PATCH 14/17] Adds GitHub Actions for deployment. --- .github/workflows/D10-Deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/D10-Deploy.yml b/.github/workflows/D10-Deploy.yml index 4700fd2fe4..5814853723 100644 --- a/.github/workflows/D10-Deploy.yml +++ b/.github/workflows/D10-Deploy.yml @@ -86,7 +86,7 @@ jobs: - name: Checkout the private repository uses: actions/checkout@v4 with: - repository: git@github.com:CityOfBoston/boston.gov-d8-private.git + repository: CityOfBoston/boston.gov-d8-private ssh-key: ${{ secrets.SSH_GITHUB_KEY }} ref: develop persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token From 27fd4447120ca293295edb8cc9e10e5db6cc4127 Mon Sep 17 00:00:00 2001 From: David Upton Date: Fri, 24 May 2024 00:04:58 -0400 Subject: [PATCH 15/17] Adds GitHub Actions for deployment. --- .github/workflows/percy_snapshot.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/percy_snapshot.yml b/.github/workflows/percy_snapshot.yml index 93db58b134..54805d6746 100644 --- a/.github/workflows/percy_snapshot.yml +++ b/.github/workflows/percy_snapshot.yml @@ -91,6 +91,9 @@ jobs: if: ${{ github.base_ref == 'production' }} runs-on: ubuntu-latest + env: + SNAPSHOT_CONFIG: "$GITHUB_WORKSPACE/.github/percy/snapshot_config_stage.yml" + defaults: run: shell: bash From 60eb131fb7e57befb8451b730d925aea9af32b07 Mon Sep 17 00:00:00 2001 From: David Upton Date: Fri, 24 May 2024 00:55:50 -0400 Subject: [PATCH 16/17] Adds GitHub Actions for deployment. --- .github/workflows/D10-GeneratePrivateRelease.yml | 6 +++--- .github/workflows/D10-GeneratePublicRelease.yml | 8 ++++---- .github/workflows/D10-Publish.yml | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/D10-GeneratePrivateRelease.yml b/.github/workflows/D10-GeneratePrivateRelease.yml index 12238710e1..fff9fc4d5f 100644 --- a/.github/workflows/D10-GeneratePrivateRelease.yml +++ b/.github/workflows/D10-GeneratePrivateRelease.yml @@ -44,7 +44,7 @@ jobs: - name: Checkout this repository uses: actions/checkout@v4 with: - path: public + path: private depth: 5 # Create the GitHub private repo Release Note. @@ -56,10 +56,10 @@ jobs: TAG: ${{ vars.THIS_TAG }} RELEASE_NOTES: "[PM to complete]" RELEASE_NUMBER: ${{ vars.THIS_RELEASE }} - WORKING_FILE: "public/CHANGELOG.md" + WORKING_FILE: "private/CHANGELOG.md" DRAFT: 0 # 1 = ReleaseNote is draft - else is published run: | - cd public + cd private printf "## ${{ env.TITLE }} ### Release By ${{ github.author }} diff --git a/.github/workflows/D10-GeneratePublicRelease.yml b/.github/workflows/D10-GeneratePublicRelease.yml index ae9b18d709..06e6654f86 100644 --- a/.github/workflows/D10-GeneratePublicRelease.yml +++ b/.github/workflows/D10-GeneratePublicRelease.yml @@ -47,16 +47,16 @@ jobs: id: Checkout-Public-Repo run: | URL=${{ secrets.PUBLIC_REPO_TARGET }} - echo "gh repo clone $URL publish -- --depth 10 --branch ${{ secrets.PUBLIC_REPO_TARGET_BRANCH }}" - gh repo clone $URL publish -- --depth=10 --branch=${{ secrets.PUBLIC_REPO_TARGET_BRANCH }} - cd publish + echo "gh repo clone $URL public -- --depth 10 --branch ${{ secrets.PUBLIC_REPO_TARGET_BRANCH }}" + gh repo clone $URL public -- --depth=10 --branch=${{ secrets.PUBLIC_REPO_TARGET_BRANCH }} + cd public git fetch origin ${{ secrets.PUBLIC_REPO_TARGET_BRANCH }} git reset --hard FETCH_HEAD # Tag the branch and push to remote. - name: Tag the branch run: | - cd publish + cd public git config --global user.email "${{ env.DEV_EMAIL }}" git config --global user.name "${{ env.USER }}" git tag -a "${{ vars.THIS_TAG }}" -m "${{ env.RELEASE_NUMBER }}" diff --git a/.github/workflows/D10-Publish.yml b/.github/workflows/D10-Publish.yml index 97dde2a44c..02c6e625db 100644 --- a/.github/workflows/D10-Publish.yml +++ b/.github/workflows/D10-Publish.yml @@ -97,7 +97,7 @@ jobs: ok=$(git tag --list | grep $ACQUIA_TAG) || break [[ $count -gt 10 ]] && exit 100 done - RELEASE_NUMBER=v10_$(date +%Y)_${{ vars.COUNT }} + RELEASE_NUMBER="v10.$(date +%Y).${{ vars.COUNT }}" [ -n "${{ github.event.pull_request.title }}" ] && TITLE="${{ github.event.pull_request.title }}" || TITLE="Boston.gov Update" [ -n "${{ github.event.pull_request.body }}" ] && BODY="${{ github.event.pull_request.body }}" || BODY="PR committed and merged." gh variable set COUNT --body $(( ${{ vars.COUNT }}+1 )) From 33e8f28ac5dff82a5dd81649f770fc16af9c34b8 Mon Sep 17 00:00:00 2001 From: David Upton Date: Fri, 24 May 2024 14:19:20 -0400 Subject: [PATCH 17/17] Adds GitHub Actions for deployment. --- .github/config/deploy/deploy-from.txt | 3 +++ .github/config/releaseNotesConfig.yml | 6 +++--- .github/workflows/D10-GeneratePublicRelease.yml | 6 +++--- .github/workflows/D10-Publish.yml | 1 + 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/config/deploy/deploy-from.txt b/.github/config/deploy/deploy-from.txt index 987032cb6c..54191efb03 100644 --- a/.github/config/deploy/deploy-from.txt +++ b/.github/config/deploy/deploy-from.txt @@ -8,3 +8,6 @@ scripts/deploy/cob_utilities.sh scripts/composer composer.lock composer.json + +.github/config/releaseNotesConfig.yml +.github/workflows/D10-NotifyRelease.yml diff --git a/.github/config/releaseNotesConfig.yml b/.github/config/releaseNotesConfig.yml index cdcdf926a0..53b50ff79a 100644 --- a/.github/config/releaseNotesConfig.yml +++ b/.github/config/releaseNotesConfig.yml @@ -1,7 +1,7 @@ username: 'Digital Team Notices' icon_url: https://boston.gov/digitalteamicon.png -pretext: A production deployment has been completed and release notes have been published. +pretext: A boston.gov deployment has been completed and release notes have been published. title: <{{payload.release.html_url}}|Code Release> title_link: {{payload.release.html_url}} @@ -16,7 +16,7 @@ fallback: |- blocks: - type: "divider" - type: "header" - text: + text: type: "plain_text" text: "Release Information" - type: section @@ -26,7 +26,7 @@ blocks: - type: mrkdwn text: "Repository Tag\n{{payload.release.tag_name}}" - type: mrkdwn - text: "Release Date\n{{truncate payload.release.created_at 10}}" + text: "Release Date\n{{truncate payload.release.created_at 10}}" - type: context elements: - type: image diff --git a/.github/workflows/D10-GeneratePublicRelease.yml b/.github/workflows/D10-GeneratePublicRelease.yml index 06e6654f86..7984311a73 100644 --- a/.github/workflows/D10-GeneratePublicRelease.yml +++ b/.github/workflows/D10-GeneratePublicRelease.yml @@ -59,8 +59,8 @@ jobs: cd public git config --global user.email "${{ env.DEV_EMAIL }}" git config --global user.name "${{ env.USER }}" - git tag -a "${{ vars.THIS_TAG }}" -m "${{ env.RELEASE_NUMBER }}" - [ ${{ vars.DRY_RUN }} == 0 ] && git push origin ${{ vars.THIS_TAG }} + git tag -a "${{ vars.THIS_RELEASE }}" -m "${{ vars.THIS_RELEASE }}" + [ ${{ vars.DRY_RUN }} == 0 ] && git push origin ${{ vars.THIS_RELEASE }} # Create the GitHub PUBLIC repo Release Note. - name: Generate Release Notes @@ -80,7 +80,7 @@ jobs: ### Release Notes ${{ env.RELEASE_NOTES }}" > ${{ env.WORKING_FILE }} options="--latest --generate-notes" - options="$options --notes-start-tag ${{ vars.LAST_TAG }}" + options="$options --notes-start-tag ${{ vars.LAST_RELEASE }}" options="$options --notes-file ${{ env.WORKING_FILE }}" options="$options --title ${{ env.RELEASE_NUMBER }}" [ ${{ env.DRAFT }} == 1 ] && options="--draft $options" diff --git a/.github/workflows/D10-Publish.yml b/.github/workflows/D10-Publish.yml index 02c6e625db..0e72957b0d 100644 --- a/.github/workflows/D10-Publish.yml +++ b/.github/workflows/D10-Publish.yml @@ -102,6 +102,7 @@ jobs: [ -n "${{ github.event.pull_request.body }}" ] && BODY="${{ github.event.pull_request.body }}" || BODY="PR committed and merged." gh variable set COUNT --body $(( ${{ vars.COUNT }}+1 )) gh variable set LAST_TAG --body "${{ vars.THIS_TAG }}" + gh variable set LAST_RELEASE --body "${{ vars.THIS_RELEASE }}" gh variable set THIS_TAG --body "$ACQUIA_TAG" gh variable set THIS_RELEASE --body "$RELEASE_NUMBER" gh variable set THIS_TITLE --body "$TITLE"