-
Notifications
You must be signed in to change notification settings - Fork 99
[No QA] Fix GitHub actions practices #733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4efa624
Immutable action refs only
roryabraham 12cbb70
Fix actionlint
roryabraham e457824
Merge branch 'main' into Rory-FixGitHubActionsPractices
roryabraham e5e8528
Two spaces instead of four in lint.yml
roryabraham 57ca071
Remove accidental npm -> yarn change
roryabraham cf0c516
Update .github/workflows/lint.yml
roryabraham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,70 +2,74 @@ name: Publish package to npmjs | |
|
|
||
| # This workflow runs when code is pushed to `main` (i.e: when a pull request is merged) | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| push: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ignored differences in indentation across files because we aren't going to enforce a yaml style (yet). But 3-space indentation was too :eye_twitch: for me to handle |
||
| branches: [main] | ||
|
|
||
| # Ensure that only once instance of this workflow executes at a time. | ||
| # If multiple PRs are merged in quick succession, there will only ever be one publish workflow running and one pending. | ||
| concurrency: ${{ github.workflow }} | ||
|
|
||
| jobs: | ||
| version: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| # OSBotify will update the version on `main`, so this check is important to prevent an infinite loop | ||
| if: ${{ github.actor != 'OSBotify' }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: main | ||
| # The OS_BOTIFY_COMMIT_TOKEN is a personal access token tied to osbotify | ||
| # This is a workaround to allow pushes to a protected branch | ||
| token: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }} | ||
|
|
||
| - name: Decrypt & Import OSBotify GPG key | ||
| run: | | ||
| cd .github | ||
| gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output OSBotify-private-key.asc OSBotify-private-key.asc.gpg | ||
| gpg --import OSBotify-private-key.asc | ||
| env: | ||
| LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} | ||
|
|
||
| - name: Set up git for OSBotify | ||
| run: | | ||
| git config --global user.signingkey 367811D53E34168C | ||
| git config --global commit.gpgsign true | ||
| git config --global user.name OSBotify | ||
| git config --global user.email infra+osbotify@expensify.com | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| registry-url: 'https://registry.npmjs.org' | ||
|
|
||
| - name: Install yarn packages | ||
| run: yarn install --immutable | ||
|
|
||
| - name: Update npm version | ||
| run: yarn version patch | ||
|
|
||
| - name: Set new version in GitHub ENV | ||
| run: echo "NEW_VERSION=$(jq '.version' package.json)" >> $GITHUB_ENV | ||
|
|
||
| - name: Commit version bump | ||
| run: git commit -am "Bump version to ${{ env.NEW_VERSION }}" | ||
|
|
||
| - name: Tag version bump | ||
| run: git tag ${{ env.NEW_VERSION }} | ||
|
|
||
| - name: Push branch and publish tags | ||
| run: git push --set-upstream origin main && git push --tags | ||
|
|
||
| - name: Build package | ||
| run: yarn pack | ||
|
|
||
| - name: Publish to npm | ||
| run: npm publish --access public | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| version: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| # OSBotify will update the version on `main`, so this check is important to prevent an infinite loop | ||
| if: ${{ github.actor != 'OSBotify' }} | ||
|
|
||
| steps: | ||
| # v5.0.0 | ||
| - name: Check out Git repository | ||
| uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 | ||
| with: | ||
| ref: main | ||
| # The OS_BOTIFY_COMMIT_TOKEN is a personal access token tied to osbotify | ||
| # This is a workaround to allow pushes to a protected branch | ||
| token: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }} | ||
|
|
||
| - name: Decrypt & Import OSBotify GPG key | ||
| run: | | ||
| cd .github | ||
| gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output OSBotify-private-key.asc OSBotify-private-key.asc.gpg | ||
| gpg --import OSBotify-private-key.asc | ||
| env: | ||
| LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} | ||
|
|
||
| - name: Set up git for OSBotify | ||
| run: | | ||
| git config --global user.signingkey 367811D53E34168C | ||
| git config --global commit.gpgsign true | ||
| git config --global user.name OSBotify | ||
| git config --global user.email infra+osbotify@expensify.com | ||
|
|
||
| # v6.0.0 | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| registry-url: 'https://registry.npmjs.org' | ||
|
|
||
| - name: Install yarn packages | ||
| run: yarn install --immutable | ||
|
|
||
| - name: Update npm version | ||
| run: yarn version patch | ||
|
|
||
| - name: Set new version in GitHub ENV | ||
| run: echo "NEW_VERSION=$(jq '.version' package.json)" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Commit version bump | ||
| run: git commit -am "Bump version to ${{ env.NEW_VERSION }}" | ||
|
|
||
| - name: Tag version bump | ||
| run: git tag ${{ env.NEW_VERSION }} | ||
|
|
||
| - name: Push branch and publish tags | ||
| run: git push --set-upstream origin main && git push --tags | ||
|
|
||
| - name: Build package | ||
| run: yarn pack | ||
|
|
||
| - name: Publish to npm | ||
| run: npm publish --access public | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition was always evaluating to true because there were characters outside of the
${{ }}