1. [on_pr] Prevent Merges on Master Allowed Hours #670
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "1. [on_pr] Prevent Merges on Master Allowed Hours" | |
on: | |
pull_request: | |
branches: | |
- master | |
types: | |
- opened | |
- synchronize | |
- edited | |
workflow_run: | |
workflows: | |
- on_schedule_rerun_check_hour | |
types: | |
- completed | |
jobs: | |
check_time: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get current time in Paris timezone with daylight saving | |
id: get_time | |
run: | | |
# Get current Paris time by adjusting UTC time | |
paris_hour=$(TZ='Europe/Paris' date +'%H') | |
echo "paris_hour=$paris_hour" >> $GITHUB_ENV | |
- name: Block merge if outside allowed hours | |
run: | | |
echo "Paris hour: ${{ env.paris_hour }}" | |
if [ $((10#$paris_hour)) -ge 18 ] || [ $((10#$paris_hour)) -lt 12 ]; then | |
echo "Merges are not allowed between 18:00 and 12:00 TZ:Europe/Paris + daylight saving." | |
exit 1 | |
else | |
echo "Merge allowed." | |
fi | |
env: | |
paris_hour: ${{ env.paris_hour }} |