Skip to content

apollo-router-updater #1102

apollo-router-updater

apollo-router-updater #1102

name: apollo-router-updater
on:
schedule:
# Every 2 hours
- cron: "0 */2 * * *"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
version:
description: "Apollo Router version"
required: true
type: string
defaults:
run:
working-directory: ./apollo-router-workspace
jobs:
update:
runs-on: ubuntu-22.04
permissions:
issues: write
pull-requests: write
contents: write
steps:
- name: checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 1
token: ${{ secrets.BOT_GITHUB_TOKEN }}
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1.17.0 # v1
with:
rust-src-dir: ./apollo-router-workspace
- name: find updates
id: check
if: ${{ github.event_name != 'workflow_dispatch' }}
run: |
LATEST_VERSION=$(curl -H "User-Agent: Apollo-Router-Updater" -s -X GET https://crates.io/api/v1/crates/apollo-router | jq -r '.crate.max_version')
echo "latest_version=$LATEST_VERSION"
echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
CURRENT_VERSION=$(cargo tree -p apollo-router | grep apollo-router | awk '{print $2}' | sed 's/^v//')
echo "current_version=$CURRENT_VERSION"
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
NEED_UPDATE=$( [ "$LATEST_VERSION" != "$CURRENT_VERSION" ] && echo 'true' || echo 'false' )
echo "update=$NEED_UPDATE"
echo "update=$NEED_UPDATE" >> $GITHUB_OUTPUT
- name: Set version from input
if: github.event_name == 'workflow_dispatch'
run: |
LATEST_VERSION="${{ github.event.inputs.version }}"
echo "latest_version=$LATEST_VERSION"
echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
CURRENT_VERSION=$(cargo tree -p apollo-router | grep apollo-router | awk '{print $2}' | sed 's/^v//')
echo "current_version=$CURRENT_VERSION"
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
NEED_UPDATE=$( [ "$LATEST_VERSION" != "$CURRENT_VERSION" ] && echo 'true' || echo 'false' )
echo "update=$NEED_UPDATE"
echo "update=$NEED_UPDATE" >> $GITHUB_OUTPUT
- name: Run updates
if: steps.check.outputs.update == 'true'
run: cargo update -p apollo-router --precise ${{ steps.check.outputs.latest_version }}
- name: Create Pull Request
if: steps.check.outputs.update == 'true'
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
commit-message: Update apollo-router to version ${{ steps.check.outputs.latest_version }}
branch: apollo-router-update-${{ steps.check.outputs.latest_version }}
delete-branch: true
title: "deps(apollo-router): update to ${{ steps.check.outputs.latest_version }}"
body: |
Automatic update of apollo-router to version ${{ steps.check.outputs.latest_version }}.
assignees: kamilkisiela,dotansimha
reviewers: kamilkisiela,dotansimha