Commit ec80c107 authored by Zhian N. Kamvar's avatar Zhian N. Kamvar
Browse files

prevent weekly workflow from running on forks

parent e19beeb2
Loading
Loading
Loading
Loading
+34 −1
Original line number Diff line number Diff line
@@ -11,9 +11,42 @@ on:
    - cron: '0 0 * * 3'

jobs:
  check-token:
    name: "Check STYLES_WORKFLOW token"
    runs-on: ubuntu-latest
    if: ${{ github.repository == 'carpentries/lesson-example' }}
    outputs:
      wf: ${{ steps.validate.outputs.wf }}
      repo: ${{ steps.validate.outputs.repo }}
    steps:
      - name: "validate token"
        id: validate
        uses: carpentries/actions/check-valid-credentials@main
        with:
          token: ${{ secrets.STYLES_WORKFLOW }}

  bad-token:
    name: "Invalid/Missing Token"
    runs-on: ubuntu-latest
    needs: check-token
    if: ${{ needs.check-token.outputs.wf != 'true' && github.repository == 'carpentries/lesson-example' }}
    steps:
      - name: "Instructions to create a new token"
        run: |
          printf "::warning::The STYLES_WORKFLOW secret is missing, invalid, "\
          "or does not have the right scope to update workflows.\n"\
          "If you want to have automated pull request updates to your workflows, "\
          "you will need to generate a new token by visiting "\
          "https://github.com/settings/tokens/new?scopes=repo,workflow&description=Styles%%20Token\n"\
          "Once you have created the token, go to "\
          "https://github.com/${{ github.repository }}/settings/secrets/actions/STYLES_WORKFLOW "\
          "to update it."

  update-styles:
    runs-on: ubuntu-20.04
    runs-on: ubuntu-latest
    name: Styles Update
    needs: check-token
    if: ${{ needs.check-token.outputs.wf == 'true' && github.repository == 'carpentries/lesson-example' }}
    steps:
      - uses: actions/checkout@v2
        with: