forked from datacommonsorg/mixer
-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (49 loc) · 2 KB
/
feature-flag-checks.yml
File metadata and controls
55 lines (49 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# This check enforces merge restrictions on feature flag changes.
#
# To work properly:
# - Its jobs should be listed as a required status checks on each listed branch
# - Each listed branch should be configured to require merge queue
#
# If the directory containing feature flag configs changes, the path filtering
# step will need to be updated.
name: Feature flag checks
on:
pull_request:
branches: ["master"]
# Required for merge queue to work: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue#triggering-merge-group-checks-with-github-actions
# Merge queue is used so that this check runs immediately before merge.
merge_group:
branches: ["master"]
permissions:
contents: read
packages: read
jobs:
enforce_feature_flag_merge_restrictions:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Detect changes to prod feature flag files
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
prod_flags:
- 'deploy/featureflags/prod*'
- name: Restrict prod feature flag changes to allowed hours
if: steps.changes.outputs.prod_flags == 'true'
run: |
# Check if the current time is between 8 AM and 5 PM California time
# on Monday, Tuesday, Wednesday, or Thursday.
set -e
export TZ="America/Los_Angeles"
CURRENT_HOUR=$(date +"%-H")
CURRENT_DAY=$(date -d "$DATE" +"%u") # 1 for Monday, 7 for Sunday
if [[ "$CURRENT_DAY" -ge 1 && "$CURRENT_DAY" -le 4 ]]; then
if [[ "$CURRENT_HOUR" -ge 8 && "$CURRENT_HOUR" -lt 17 ]]; then
echo "Current time is within the allowed window for prod flag changes."
exit 0
fi
fi
echo "Error: Prod flag changes are only allowed between 8 AM and 5 PM California time on Monday-Thursday."
exit 1