Paypal integration #20
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
| name: Release From PR Comment | |
| on: | |
| issue_comment: | |
| types: [created] | |
| jobs: | |
| release: | |
| if: | | |
| github.event.issue.pull_request && | |
| github.event.action == 'created' && | |
| startsWith(github.event.comment.body, '/release ') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: read | |
| issues: read | |
| steps: | |
| - name: Ensure commenter is allowed | |
| if: | | |
| github.event.comment.author_association != 'OWNER' && | |
| github.event.comment.author_association != 'MEMBER' | |
| run: | | |
| echo "Only OWNER or MEMBER can trigger releases." | |
| exit 1 | |
| - name: Validate PR merged to main and parse version | |
| id: guard | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const prNumber = context.payload.issue.number; | |
| const comment = context.payload.comment.body.trim(); | |
| const match = comment.match(/^\/release\s+(\d+\.\d+\.\d+)$/); | |
| if (!match) { | |
| core.setFailed("Invalid command. Use: /release <major.minor.patch>"); | |
| return; | |
| } | |
| const version = match[1]; | |
| const pr = await github.rest.pulls.get({ | |
| owner, | |
| repo, | |
| pull_number: prNumber, | |
| }); | |
| if (!pr.data.merged) { | |
| core.setFailed("PR is not merged."); | |
| return; | |
| } | |
| if (pr.data.base.ref !== "main") { | |
| core.setFailed("PR was not merged into main."); | |
| return; | |
| } | |
| core.setOutput("version", version); | |
| - name: Checkout main | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 23.x | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Configure git | |
| run: | | |
| git config --global user.name 'CodeLit' | |
| git config --global user.email 'hi@codelit.dev' | |
| git remote set-url origin https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }} | |
| env: | |
| GITHUB_PAT: ${{ secrets.PAT }} | |
| - name: Run release script | |
| env: | |
| VERSION: ${{ steps.guard.outputs.version }} | |
| run: | | |
| pnpm release "$VERSION" | |
| - name: Setup buildx | |
| uses: docker/setup-buildx-action@v1 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKERNAME }} | |
| password: ${{ secrets.DOCKERTOKEN }} | |
| - name: Build and push app image | |
| id: docker_build_app | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: . | |
| file: ./services/app/Dockerfile | |
| push: true | |
| tags: | | |
| codelit/courselit-app:v${{ steps.guard.outputs.version }} | |
| codelit/courselit-app:latest | |
| - name: Echo app image digest | |
| run: echo ${{ steps.docker_build_app.outputs.digest }} | |
| - name: Build and push queue image | |
| id: docker_build_queue | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: . | |
| file: ./services/queue/Dockerfile | |
| push: true | |
| tags: | | |
| codelit/courselit-queue:v${{ steps.guard.outputs.version }} | |
| codelit/courselit-queue:latest | |
| - name: Echo queue image digest | |
| run: echo ${{ steps.docker_build_queue.outputs.digest }} |