Skip to content

Commit

Permalink
ci: adjust ci/cd
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurTriis1 committed Oct 10, 2024
1 parent cfe0c35 commit 3ea566c
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 14 deletions.
78 changes: 74 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
name: CI

on:
push:
branches-ignore:
- main
pull_request:
types: [opened, reopened]

jobs:
build:
Expand All @@ -22,10 +21,81 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'
cache: "yarn"

- name: Install dependencies
run: yarn

- name: Build
run: yarn build

choose-version:
runs-on: ubuntu-latest

steps:
- name: Add version selection comment
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `
## Please select the version update for the package:
- 👍 Patch
- 🎉 Minor
- 🚀 Major
React with the appropriate emoji to choose the version.
`
})
check-version:
runs-on: ubuntu-latest
needs: choose-version
steps:
- name: Check version bump reaction
uses: actions/github-script@v6
with:
script: |
const { data: reactions } = await github.rest.reactions.listForIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
let versionType = 'patch'; // default
reactions.forEach(reaction => {
if (reaction.content === 'rocket') {
versionType = 'major';
} else if (reaction.content === 'tada') {
versionType = 'minor';
}
});
console.log(`Version to bump: ${versionType}`);
core.setOutput('version_type', versionType);
release:
runs-on: ubuntu-latest
needs: check-version
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org/'

- name: Bump version
run: |
yarn version --${{ needs.check-version.outputs.version_type }}
- name: Push changes and tags
run: |
git config user.email "[email protected]"
git config user.name "vtexgithubbot"
git push --follow-tags
11 changes: 1 addition & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,7 @@ jobs:
- name: Build
run: yarn build

- name: Update version to patch
run: yarn version --patch

- name: Publish
run: yarn publish --non-interactive
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Push changes and tags
run: |
git config user.email "[email protected]"
git config user.name "vtexgithubbot"
git push --follow-tags
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 3ea566c

Please sign in to comment.