Skip to content

Commit

Permalink
Merge pull request #503 from zmap/phillip/fix-tlsa-action
Browse files Browse the repository at this point in the history
Fix GH Action for automatically pulling TLSA record
  • Loading branch information
phillip-stephens authored Jan 10, 2025
2 parents ade0136 + 2e017ec commit 68f2c95
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
36 changes: 17 additions & 19 deletions .github/workflows/check_tlsa_integration_test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Daily TLSA integration test update action
name: Update TLSA records in integration tests
# Our integration tests run against "_25._tcp.mail.ietf.org" which periodically changes its TLSA records.
# This action uses 'dig' to make a PR whenever the TLSA record is updated.

Expand Down Expand Up @@ -94,31 +94,29 @@ jobs:
' "$TEST_FILE" > temp_file && mv temp_file "$TEST_FILE"
# Re-format with `black` to ensure consistent style
pip3 install black
black "$TEST_FILE"
echo "Updated $TEST_FILE with properly indented TLSA records."
# Check if the file was updated
if ! git diff --exit-code "$TEST_FILE"; then
echo "File updated."
echo "file_updated=true" >> $GITHUB_ENV
else
echo "No changes detected."
fi
- name: Commit and push changes
if: env.file_updated == 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b update-tlsa-record
git add path/to/test_file.py
git commit -m "Update TLSA records"
git push -u origin update-tlsa-record
# Check if the file was updated
if ! git diff --exit-code "$TEST_FILE"; then
echo "File updated."
echo "file_updated=true" >> $GITHUB_ENV
else
echo "No changes detected."
fi
# Cleanup temp file
rm tlsa.json
- name: Create Pull Request
if: env.file_updated == 'true'
uses: peter-evans/create-pull-request@v5
with:
title: "Update TLSA records"
body: "This PR updates the TLSA records in the test file."
branch: update-tlsa-record
base: main
branch: update-tlsa-record-${{ github.run_id }}
delete-branch: false
author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
draft: true
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ on:
branches:
- main
pull_request:
types: [opened, ready_for_review, synchronize]
workflow_dispatch:

jobs:
check-license:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down

0 comments on commit 68f2c95

Please sign in to comment.