forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 8
79 lines (70 loc) · 3.75 KB
/
connector_code_freeze.yml
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# This workflow is meant to be used to prevent/discourage merging to master during code freeze.
# The code freeze dates are set in the env variables CODE_FREEZE_START_DATE and CODE_FREEZE_END_DATE.
# If any connector code has been changed we display a warning message reminding merging is blocked and who to contact.
# If no connector connector code has been changed we only display a warning message reminding merging is discouraged.
# The Code freeze check job will be set as a required check for PRs in branch protection rules.
name: Code freeze
on:
pull_request:
types:
- opened
- synchronize
- ready_for_review
env:
CODE_FREEZE_START_DATE: "2023-12-21"
CODE_FREEZE_END_DATE: "2024-01-02"
jobs:
code-freeze-check:
runs-on: ubuntu-latest
name: Code freeze check
permissions:
# This is required to be able to comment on PRs and list changed files
pull-requests: write
steps:
# Check if code freeze is in effect by comparing the current date with the start and end date of the code freeze
- name: Check code freeze in effect
id: check-code-freeze-in-effect
run: |
start_date=$(date -d "$CODE_FREEZE_START_DATE" +%s)
end_date=$(date -d "$CODE_FREEZE_END_DATE" +%s)
current_date=$(date +%s)
if [ "$current_date" -ge "$start_date" ] && [ "$current_date" -le "$end_date" ]; then
echo "Code freeze is in effect"
echo "::set-output name=is_in_code_freeze::true"
else
echo "Code freeze is not in effect"
echo "::set-output name=is_in_code_freeze::false"
fi
# Use GitHub PR Api to get the list of changed files
# Filter the list to only keep the connectors files
- name: Get changed files
if: steps.check-code-freeze-in-effect.outputs.is_in_code_freeze == 'true'
id: changed-files
uses: tj-actions/changed-files@v44
with:
files_yaml: |
connectors:
- 'airbyte-integrations/connectors/**'
- '!**/*.md'
# If any connector code has been changed we display a warning message reminding merging is blocked and who to contact
- name: Code freeze comment on PR
if: steps.changed-files.outputs.connectors_any_changed == 'true' && steps.check-code-freeze-in-effect.outputs.is_in_code_freeze == 'true'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: code_freeze_warning
message: |
> [!WARNING]
> <b>🚨 Connector code freeze is in effect until ${{ env.CODE_FREEZE_END_DATE }}. This PR is changing connector code. Please contact the current OC engineers if you want to merge this change to master.</b>
# If no connector code has been changed we only display a warning message reminding merging is discouraged
- name: Code freeze comment on PR
if: steps.changed-files.outputs.connectors_any_changed == 'false' && steps.check-code-freeze-in-effect.outputs.is_in_code_freeze == 'true'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: code_freeze_warning
message: |
> [!WARNING]
> <b>Soft code freeze is in effect until ${{ env.CODE_FREEZE_END_DATE }}. Please avoid merging to master. #freedom-and-responsibility</b>
# Fail the workflow if connector code has been changed to prevent merging to master
- name: Fail workflow if connector code has been changed
if: steps.changed-files.outputs.connectors_any_changed == 'true' && steps.check-code-freeze-in-effect.outputs.is_in_code_freeze == 'true'
run: echo "Connector code freeze is in effect. Please contact the current OC engineers if you want to merge this change." && exit 1