Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh Tugboat Preview ID cache from PR cache scope #16562

Merged
merged 1 commit into from
Dec 22, 2023

Conversation

JunTaoLuo
Copy link
Contributor

@JunTaoLuo JunTaoLuo commented Dec 22, 2023

Description

Resolves #16561

Testing done

Tested in va.gov-cms-test using department-of-veterans-affairs/va.gov-cms-test#1469. The last two triggered refreshes were successful. Note the name of the workflow job was updated to clarify functionality.

Screenshots

image image

QA steps

TBD

  • The cache refresh workflow is tested in this PR. The cron trigger update won't take effect until merged to main.

Definition of Done

  • Documentation has been updated, if applicable.
  • Tests have been added if necessary.
  • Automated tests have passed.
  • Code Quality Tests have passed.
  • Acceptance Criteria in related issue are met.
  • Manual Code Review Approved.
  • If there are field changes, front end output has been thoroughly checked.

Select Team for PR review

  • CMS Team
  • Public websites
  • Facilities
  • User support
  • Accelerated Publishing

@JunTaoLuo JunTaoLuo requested a review from a team as a code owner December 22, 2023 22:25
@va-cms-bot va-cms-bot temporarily deployed to Tugboat December 22, 2023 22:25 Destroyed
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
github-token: ${{ secrets.LABEL_API_TOKEN }}
Copy link
Contributor Author

@JunTaoLuo JunTaoLuo Dec 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default identity github-actions (bot) does not trigger the pull_request: labeled event. I'm not sure why this is but a PAT will trigger the event correctly. (I suspect this to be a github-actions bug)

Note the PAT needed these permissions:

  1. repo admin read/write
  2. issues read/write
  3. pull request read/write

The current fine-grained token has these permissions for va.gov-cms and va.gov-cms-test repos only.

if: ${{ github.event.label.name == 'refresh-tugboat-cache' }}
steps:
- name: Refresh Preview ID
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to cache scoping, actions/cache/restore will only work if triggered from some type of pull_request event.

for (const pr of prs) {
if (cacheKeys.includes(`${{ runner.os }}-tugboat-preview-id-pr-${pr}`)) {
console.log(`Need to refresh: ${pr}`)
toRefresh.push(pr)
await github.rest.issues.addLabels({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pull_request: label seems to be the least disruptive event. Alternatively we can use any of the other pull request events.

@JunTaoLuo JunTaoLuo added the refresh-tugboat-cache Used by GHA Tugboat automation label Dec 22, 2023
@github-actions github-actions bot removed the refresh-tugboat-cache Used by GHA Tugboat automation label Dec 22, 2023
@github-actions github-actions bot added the CMS Team CMS Product team that manages both editor exp and devops label Dec 22, 2023
@JunTaoLuo JunTaoLuo force-pushed the 16561-refresh-cache-entries branch from 3c6ea45 to dc9614d Compare December 22, 2023 23:23
@va-cms-bot va-cms-bot temporarily deployed to Tugboat December 22, 2023 23:23 Destroyed
Copy link

github-actions bot commented Dec 22, 2023

GitHub Workflows (.github/workflows/*.yml)

Have you...

  • pinned all affected GitHub Actions at a specific commit by SHA?
  • reviewed the source code of the action at the commit you are pinning?
  • confirmed that no GitHub security measures are being bypassed?
  • checked for any injection of user content into protected contexts?
  • reviewed Security hardening for GitHub Actions?
  • reviewed GitHub Workflows?

@JunTaoLuo JunTaoLuo merged commit 48de27e into main Dec 22, 2023
19 checks passed
@JunTaoLuo JunTaoLuo deleted the 16561-refresh-cache-entries branch December 22, 2023 23:45
@JunTaoLuo JunTaoLuo mentioned this pull request Jan 8, 2024
5 tasks
JunTaoLuo added a commit that referenced this pull request Jan 24, 2024
JunTaoLuo added a commit that referenced this pull request Jan 24, 2024
@JunTaoLuo JunTaoLuo mentioned this pull request Feb 1, 2024
32 tasks
JunTaoLuo added a commit that referenced this pull request Feb 1, 2024
JunTaoLuo added a commit that referenced this pull request Feb 2, 2024
JunTaoLuo added a commit that referenced this pull request Feb 2, 2024
* Revert "Add documentation for Tugboat GHA integration (#16739)"

This reverts commit e5bce05.

* Revert "Refresh Tugboat Preview ID cache from PR cache scope (#16562)"

This reverts commit 48de27e.

* Revert "Minimize PR overhead for non-code changes (#16279)"

This reverts commit 176aa38.

* Update documentation (#17123)

* Test PR with documentation change

* Update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CMS Team CMS Product team that manages both editor exp and devops
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Github Actions Cache refresh cannot be triggered from the main branch
3 participants