Skip to content

Update AWS IP Ranges #123

Update AWS IP Ranges

Update AWS IP Ranges #123

name: Update AWS IP Ranges
on:
# run if manually triggered
workflow_dispatch:
# run if something on the `main` branch changes
push:
branches:
- main
# run every hour at XX:42
schedule:
- cron: "42 * * * *"
permissions:
contents: write
concurrency:
group: update-aws-ip-ranges
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2
id: app-token
with:
app-id: ${{ vars.WORKFLOWS_CRATES_IO_APP_ID }}
private-key: ${{ secrets.WORKFLOWS_CRATES_IO_PRIVATE_KEY }}
- name: Get GitHub App User ID
id: get-user-id
run: echo "user-id=$(gh api "/users/${APP_SLUG}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- run: git config --global user.name "${APP_SLUG}[bot]"
env:
APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
- run: git config --global user.email "${USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com"
env:
APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
USER_ID: ${{ steps.get-user-id.outputs.user-id }}
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
token: ${{ steps.app-token.outputs.token }}
persist-credentials: true
- run: python3 crates/crates_io_real_ip/update-data.py
- run: git diff --exit-code
id: git-diff
continue-on-error: true
# Prevent build failures from getting a git commit
- run: cargo check --package crates_io_real_ip
if: steps.git-diff.outcome == 'failure'
- run: git commit --all --message "Update AWS IP ranges data"
if: steps.git-diff.outcome == 'failure'
- run: git push origin main
if: steps.git-diff.outcome == 'failure'