From ab000fe908de027f2e2bd49be2d1b43309e9814d Mon Sep 17 00:00:00 2001 From: Ronnie Miller Date: Tue, 18 Mar 2025 06:41:34 -0700 Subject: [PATCH] docs: opt-in draft docs builds to stale cleanup (#7117) --- .github/workflows/deploy-docs-draft.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/deploy-docs-draft.yml b/.github/workflows/deploy-docs-draft.yml index 6edf0890c..d41270bf9 100644 --- a/.github/workflows/deploy-docs-draft.yml +++ b/.github/workflows/deploy-docs-draft.yml @@ -147,6 +147,10 @@ jobs: mv build langflow-drafts/${{ steps.extract_branch.outputs.draft_directory }} cd langflow-drafts + # Records the repository that originally triggered the build so we can post back + # comments upon clean up of a stale draft if it still has an open pull request. + echo "${{ github.event.repository.full_name }}" > ${{ steps.extract_branch.outputs.draft_directory }}/.github_source_repository + s3_params=( # Hide upload progress for a cleaner sync log --no-progress @@ -162,6 +166,19 @@ jobs: echo "aws s3 sync . s3://${{ vars.DOCS_DRAFT_S3_BUCKET_NAME }}/langflow-drafts ${s3_params[@]}" |& tee -a $GITHUB_WORKSPACE/deploy.log aws s3 sync . "s3://${{ vars.DOCS_DRAFT_S3_BUCKET_NAME }}/langflow-drafts" "${s3_params[@]}" |& tee -a $GITHUB_WORKSPACE/deploy.log + # Update .github_source_repository file metadata to mark last modified time of the draft. + # This will allow us to later determine if a draft is stale and needs to be cleaned up. + echo "Marking last modified time of the draft." |& tee -a $GITHUB_WORKSPACE/deploy.log + echo "aws s3 cp --metadata '{\"touched\": \"now\"}' \ + s3://${{ vars.DOCS_DRAFT_S3_BUCKET_NAME }}/langflow-drafts/${{ steps.extract_branch.outputs.draft_directory }}/.github_source_repository \ + s3://${{ vars.DOCS_DRAFT_S3_BUCKET_NAME }}/langflow-drafts/${{ steps.extract_branch.outputs.draft_directory }}/.github_source_repository" \ + |& tee -a $GITHUB_WORKSPACE/deploy.log + + aws s3 cp --metadata '{ "touched": "now" }' \ + s3://${{ vars.DOCS_DRAFT_S3_BUCKET_NAME }}/langflow-drafts/${{ steps.extract_branch.outputs.draft_directory }}/.github_source_repository \ + s3://${{ vars.DOCS_DRAFT_S3_BUCKET_NAME }}/langflow-drafts/${{ steps.extract_branch.outputs.draft_directory }}/.github_source_repository \ + |& tee -a $GITHUB_WORKSPACE/deploy.log + - name: Invalidate CloudFront Cache if: success() run: |