Skip to content

Update Ip Ranges

Update Ip Ranges #46

Workflow file for this run

name: Update Ip Ranges
permissions:
contents: write # Ensure permissions to push changes and create tags
actions: write # Allow triggering other workflows
on:
schedule:
- cron: '0 0 * * *' # Runs every day at midnight
workflow_dispatch: # Allows manual triggering
jobs:
update_ranges:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.22"
cache: false
- name: Checkout code
uses: actions/checkout@v3
with:
persist-credentials: true # Keeps GitHub token for pushing changes
fetch-depth: 0 # Fetch all history for all tags and branches
- name: Setup deps
run: make setup
- name: Set up Git user
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
- name: Run pre-build
run: make pre-build
- name: Check for changes
id: git_diff
run: git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT
- name: Lint, build, test before release
if: steps.git_diff.outputs.changes == 'true'
run: make lint build test
- name: Get latest tag
if: steps.git_diff.outputs.changes == 'true'
id: get_tag
run: |
LATEST_TAG="v$(make get-version)"
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
- name: Calculate new tag
if: steps.git_diff.outputs.changes == 'true'
id: new_tag
env:
LATEST_TAG: ${{ steps.get_tag.outputs.latest_tag }}
run: |
IFS='.' read -r major minor patch <<< "$LATEST_TAG"
major=${major:-0}
minor=${minor:-0}
patch=${patch:-0}
new_patch=$((patch + 1))
NEW_TAG="$major.$minor.$new_patch"
echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
- name: Commit and push changes with new tag
if: steps.git_diff.outputs.changes == 'true'
env:
NEW_TAG: ${{ steps.new_tag.outputs.new_tag }}
run: |
git add -A
git commit -m "chore: auto update IP ranges - $NEW_TAG"
git tag "$NEW_TAG"
git push origin main --tags
# Release
- uses: goreleaser/goreleaser-action@v4
name: Release new patch
if: steps.git_diff.outputs.changes == 'true'
with:
args: "release --clean"
version: latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"