Skip to content

Commit

Permalink
Removing listening to changes on Connectors - build perf (#693)
Browse files Browse the repository at this point in the history
* Cleaning up the code a bit
Adding some logging for performance

* Reverting an temporary change

* Putting the preview build back to what it was
Expecting the label to be there right from the start
Trying to schedule prod builds unless strapi was updated

* updating PR template to make sure people know about process

* making a bit more readable
  • Loading branch information
travjenkins authored Feb 20, 2025
1 parent c8e056d commit 3a65b99
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Label `generate-pr-preview` required before opening PR for preview build

## Changes

- changes...
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ name: Deploy to Firebase Preview

on:
pull_request:
types:
[
opened,
synchronize,
reopened,
labeled,
unlabeled,
ready_for_review,
]

concurrency:
group: preview-${{ github.ref }}
Expand Down Expand Up @@ -54,7 +45,6 @@ jobs:

- name: Run build
run: yarn run build --log-pages
if: ${{ github.event.pull_request.draft != true }}
env:
CI: true
STRAPI_API_URL: ${{ secrets.STRAPI_API_URL }}
Expand All @@ -66,7 +56,7 @@ jobs:
GATSBY_DB_NAME: ${{ secrets.GATSBY_DB_NAME }}

- uses: FirebaseExtended/action-hosting-deploy@v0
if: ${{ github.event.pull_request.draft != true && contains(github.event.pull_request.labels.*.name, 'generate-pr-preview') }}
if: ${{ contains(github.event.pull_request.labels.*.name, 'generate-pr-preview') }}
id: firebase
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
Expand Down
54 changes: 53 additions & 1 deletion .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
name: Deploy to Firebase Hosting

on:
# TODO scheduled builds
# schedule:
# - cron: '0 5 * * *' # ~ midnight eastern
# - cron: '0 13 * * *' # ~ 8 am eastern
# - cron: '0 17 * * *' # ~ noon eastern
# - cron: '0 23 * * *' # ~ 6 pm eastern
workflow_dispatch:
repository_dispatch:
types: [strapi_updated, database_updated]
types: [strapi_updated]
push:
branches:
- master
Expand All @@ -12,8 +18,54 @@ concurrency:
group: prod

jobs:
# TODO scheduled builds
# check-recent-build:
# runs-on: ubuntu-latest

# steps:
# - name: Check if triggered by cron
# id: check_trigger
# run: |
# if [ "${{ github.event_name }}" != "schedule" ]; then
# echo "This build was not triggered by a cron job. Skipping previous build checking."
# echo "::set-output name=should_check_build::false"
# echo "::set-output name=should_run::true"
# else
# echo "::set-output name=should_check_build::true"
# fi

# - name: Get previous workflow status
# id: get_last_status
# uses: adel-s/get-last-workflow-run-info@v1
# if: ${{ steps.check_trigger.outputs.should_check_build == 'true' }}
# with:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: Get previous successful workflow run
# id: previous_successful_run
# if: ${{ steps.check_trigger.outputs.should_check_build == 'true' }}
# run: |
# # Get the current time and calculate the timestamp for 1 hour ago
# current_time=$(date +%s)
# one_hour_ago=$((current_time - 3600))

# # Get the latest successful run of the 'build_and_preview' job
# previous_run=$(gh api repos/${{ github.repository }}/actions/runs \
# --jq ".workflow_runs | map(select(.status == 'success' and .created_at | fromdateiso8601 > $one_hour_ago)) | .[0]")

# if [ -z "$previous_run" ]; then
# echo "No successful build in the past hour. Proceeding with the job."
# echo "::set-output name=should_run::true"
# else
# echo "A successful build was found in the past hour. Skipping the build."
# echo "::set-output name=should_run::false"
# fi

build_and_preview:
runs-on: ubuntu-2404-large
# TODO scheduled builds
# needs: check-recent-build
# if: ${{ needs.check-recent-build.outputs.should_run == 'true' }}
steps:
- env:
MESSAGE: ${{ toJson(github.event.client_payload) }}
Expand Down

0 comments on commit 3a65b99

Please sign in to comment.