Skip to content

Conversation

@mollyIV
Copy link
Member

@mollyIV mollyIV commented Jan 12, 2020

Description

The communicate-on-pull-request-merged GitHub Action fails in most cases due to:

##[error]Input required and not supplied: repo-token
##[error]Docker run failed with exit code 1 

It turns out that when a user opens a pull request on the base project from a fork, no secrets are provided to the workflow. According to the GitHub Actions documentation:

With the exception of GITHUB_TOKEN, secrets are not passed to the runner when a workflow is triggered from a forked repository.

Workaround

As a workaround, to being able to use the secrets in a workflow, we can use a push event to trigger the workflow. In the action itself, we can parse the detailed information about the push 💡

Testing

A workflow file used for a manual testing:

name: Processing pull requests
on: 
  push:
    branches: master

jobs:   
  communicate-on-pull-request-merged:
    name: communicate on pull request merged
    runs-on: ubuntu-latest    
    steps:
      - name: Git checkout
        uses: actions/checkout@master
        with:
          ref: refs/heads/master
      
      - name: Communicate on PR merged
        uses: mollyIV/github-actions/communicate-on-pull-request-merged@change-the-coprm-action-to-be-executed-on-push-event
        with:
          repo-token: ${{ secrets.BOT_GITHUB_TOKEN }}
          pr-label-to-add: 'status: included-in-next-release'
          pr-label-to-remove: 'status: needs-attention'

Screen Shot 2020-01-12 at 21 07 11

The bot is set to my private account, that's why you see the comments from the author.

The unit tests have been updated too.

🎊 🎊

@mollyIV mollyIV marked this pull request as ready for review January 12, 2020 20:19
@mollyIV mollyIV requested a review from joshdholtz January 12, 2020 20:20
mollyIV added a commit to fastlane/fastlane that referenced this pull request Jan 12, 2020
### Description 

Please check [this](fastlane/github-actions#29 (comment)) for a detailed description. 

Disabling a `pull-requests.yml` workflow is safe due to the [bot's backup](https://github.com/fastlane/issue-bot).
Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be easier if we just rename the secret to GITHUB_TOKEN in our secrets? 🤔

@mollyIV
Copy link
Member Author

mollyIV commented Jan 28, 2020

Hey @joshdholtz 👋

Would it be easier if we just rename the secret to GITHUB_TOKEN in our secrets? 🤔

According to the documentation:

GitHub automatically creates a GITHUB_TOKEN secret to use in your workflow. You can use the GITHUB_TOKEN to authenticate in a workflow run.

Taking that into account, I tried to add GITHUB_TOKEN to the secrets on my private repo, where the GitHub Actions are enabled:

Screen Shot 2020-01-28 at 07 35 50

💣 💥

If we were able to override GITHUB_TOKEN via our env variable in secrets, the benefit would be not adding repo-token: ${{ secrets.BOT_GITHUB_TOKEN }} to the action in a workflow file. However I do not think it bothers us 👍

mollyIV added a commit to fastlane/fastlane that referenced this pull request Jan 28, 2020
### Description 

Please check [this](fastlane/github-actions#29 (comment)) for a detailed description. 

Disabling a `pull-requests.yml` workflow is safe due to the [bot's backup](https://github.com/fastlane/issue-bot).
@mollyIV mollyIV self-assigned this Feb 18, 2020
@mollyIV
Copy link
Member Author

mollyIV commented Apr 18, 2020

Hey @joshdholtz 👋

Did you get a chance to have a look at these changes? 😊

minuscorp pushed a commit to minuscorp/fastlane that referenced this pull request Jul 18, 2020
### Description 

Please check [this](fastlane/github-actions#29 (comment)) for a detailed description. 

Disabling a `pull-requests.yml` workflow is safe due to the [bot's backup](https://github.com/fastlane/issue-bot).
Copy link
Member

@iBotPeaches iBotPeaches left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me since target of the PR may not live in the fastlane org, so no secrets.

I updated it locally, scanned around and ran tests - all seems good.

Test Suites: 1 passed, 1 total
Tests:       5 passed, 5 total
Snapshots:   0 total
Time:        0.607s
Ran all test suites.

Since I adapted CI to block changes to lib - I'm guessing if this is brought up to date it'll fail CI. The CI system will update distribution files now, so if you want to go forward with merging this we can just merge in master and revert changes to lib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants