|
| 1 | +name: Backend |
| 2 | +on: |
| 3 | + push: |
| 4 | + # paths: |
| 5 | + # - "backend/**" |
| 6 | + paths-ignore: |
| 7 | + - "**/*.md" |
| 8 | + - "**/*.mdx" |
| 9 | + - "**/**.example.*" |
| 10 | + |
| 11 | +jobs: |
| 12 | + ci: |
| 13 | + name: CI |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Comment on PR |
| 18 | + uses: actions/github-script@v7 |
| 19 | + with: |
| 20 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + script: | |
| 22 | + const prNumber = context.payload.pull_request.number; |
| 23 | + const owner = context.repo.owner; |
| 24 | + const repo = context.repo.repo; |
| 25 | +
|
| 26 | + const message = ` 🐳 Backend successfully built and published to [hub.docker.com/r/krystxf/metro-now-backend](https://hub.docker.com/r/krystxf/metro-now-backend/tags)!🎉; |
| 27 | +
|
| 28 | + github.rest.issues.createComment({ |
| 29 | + issue_number: prNumber, |
| 30 | + owner: owner, |
| 31 | + repo: repo, |
| 32 | + body: message |
| 33 | + }); |
| 34 | +
|
| 35 | + - uses: actions/checkout@v4 |
| 36 | + - uses: oven-sh/setup-bun@v1 |
| 37 | + |
| 38 | + - run: | |
| 39 | + cd ./backend |
| 40 | + bun install |
| 41 | + bun run build |
| 42 | +
|
| 43 | + publish-docker-image: |
| 44 | + needs: ci |
| 45 | + runs-on: ubuntu-latest |
| 46 | + # if: github.ref == 'refs/heads/main' |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Checkout |
| 50 | + uses: actions/checkout@v4 |
| 51 | + |
| 52 | + - name: Set up QEMU |
| 53 | + uses: docker/setup-qemu-action@v3 |
| 54 | + |
| 55 | + - name: Set up Docker Buildx |
| 56 | + uses: docker/setup-buildx-action@v3 |
| 57 | + |
| 58 | + - name: Login to Docker Hub |
| 59 | + uses: docker/login-action@v3 |
| 60 | + with: |
| 61 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 62 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 63 | + |
| 64 | + - name: Build and publish |
| 65 | + uses: docker/build-push-action@v5 |
| 66 | + with: |
| 67 | + context: ./backend |
| 68 | + push: true |
| 69 | + tags: krystxf/metro-now-backend:latest |
| 70 | + |
| 71 | + - name: Create commit comment |
| 72 | + uses: peter-evans/commit-comment@v3 |
| 73 | + id: cc |
| 74 | + with: |
| 75 | + body: | |
| 76 | + 🐳Backend successfully built and published to [Docker Hub](https://hub.docker.com/r/krystxf/metro-now-backend/tags)!🎉 |
| 77 | + - name: Check outputs |
| 78 | + run: | |
| 79 | + echo "Comment ID - ${{ steps.cc.outputs.comment-id }}" |
0 commit comments