Update MTA-STS #6
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: Daily MTA-STS Update | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Runs every day at midnight UTC | |
workflow_dispatch: # Allows manual triggering of the workflow | |
jobs: | |
update-mta-sts: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.ACCESS_TOKEN }} | |
- name: Fetch MTA-STS Policy | |
run: | | |
curl -s https://mta-sts.protonmail.com/.well-known/mta-sts.txt > .well-known/mta-sts.txt | |
- name: Replace `max_age` and `mode` values (Testing) | |
run: | | |
# Replace max_age with 86400 | |
sed -i 's/^max_age: .*/max_age: 86400/' .well-known/mta-sts.txt | |
# Replace mode with testing | |
sed -i 's/^mode: .*/mode: testing/' .well-known/mta-sts.txt | |
# - name: Commit and push updated file | |
# run: | | |
# git config --global user.name "github-actions[bot]" | |
# git config --global user.email "[email protected]." | |
# git add .well-known/mta-sts.txt | |
# git commit -m "Update MTA-STS policy on $(date +'%Y-%m-%d')" | |
# git push | |
- name: Check for changes | |
id: check_changes | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "[email protected]." | |
git add .well-known/mta-sts.txt | |
if git diff --cached --quiet; then | |
echo "No changes detected." | |
echo "changes=false" >> $GITHUB_ENV | |
else | |
echo "Changes detected." | |
echo "changes=true" >> $GITHUB_ENV | |
fi | |
- name: Commit and push updated file | |
if: env.changes == 'true' | |
run: | | |
git commit -m "Update MTA-STS policy on $(date +'%Y-%m-%d')" | |
git push |