github-app-token icon indicating copy to clipboard operation
github-app-token copied to clipboard

fix: Don't try to revoke a token that has already expired

Open wwsean08 opened this issue 1 year ago • 0 comments

This is a PR to fix when a CI job fails because it tries to revoke a token which has already expired. Given that github provides the expiration time, it's worth referencing that and preventing the error in the first place.

Testing

This was tested using an internal repostiory, below are the workflow files and the results:

Skipping revoke as it's expired

name: Testing app rejection update
on:
  push:
    branches:
      - sean-smith-test

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: checkout code
        uses: actions/checkout@v4
      - name: Setup app token
        uses: wwsean08/github-app-token@v2
        with:
          app_id: ${{ secrets.APP_READ_ALL_REPOS_ID }}
          private_key: ${{ secrets.APP_READ_ALL_REPOS_KEY_B64 }}
      - name: Sleep for about an hour
        run: sleep 61m

Screenshot 2024-04-01 at 3 39 47 PM

Revoking as it's not expired

name: Testing app rejection update
on:
  push:
    branches:
      - sean-smith-test

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: checkout code
        uses: actions/checkout@v4
      - name: Setup app token
        uses: wwsean08/github-app-token@v2
        with:
          app_id: ${{ secrets.APP_READ_ALL_REPOS_ID }}
          private_key: ${{ secrets.APP_READ_ALL_REPOS_KEY_B64 }}
      - name: Sleep for about an hour
        run: sleep 5

Screenshot 2024-04-01 at 3 41 06 PM

wwsean08 avatar Apr 01 '24 21:04 wwsean08