|
| 1 | +name: Build and deploy |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + build-frontend: |
| 15 | + runs-on: [self-hosted] |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v3 |
| 18 | + - name: Login to Docker Hub |
| 19 | + uses: docker/login-action@v3 |
| 20 | + if: github.event_name != 'pull_request' |
| 21 | + with: |
| 22 | + username: ${{ vars.DOCKERHUB_USERNAME }} |
| 23 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 24 | + - name: Set up Docker Buildx |
| 25 | + uses: docker/setup-buildx-action@v3 |
| 26 | + - name: Setup env |
| 27 | + run: | |
| 28 | + cp .env.deploy .env |
| 29 | + - name: Build and push |
| 30 | + uses: docker/build-push-action@v6 |
| 31 | + with: |
| 32 | + context: . |
| 33 | + file: .docker/frontend/Dockerfile |
| 34 | + push: ${{ github.event_name != 'pull_request' }} |
| 35 | + pull: true |
| 36 | + tags: | |
| 37 | + ksetcomp/jobfair-2022-frontend:latest |
| 38 | + ksetcomp/jobfair-2022-frontend:${{ github.sha }} |
| 39 | +
|
| 40 | + build-backend: |
| 41 | + runs-on: [self-hosted] |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v3 |
| 44 | + - name: Login to Docker Hub |
| 45 | + uses: docker/login-action@v3 |
| 46 | + if: github.event_name != 'pull_request' |
| 47 | + with: |
| 48 | + username: ${{ vars.DOCKERHUB_USERNAME }} |
| 49 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 50 | + - name: Set up Docker Buildx |
| 51 | + uses: docker/setup-buildx-action@v3 |
| 52 | + - name: Setup env |
| 53 | + run: | |
| 54 | + cp .env.example ./backend/.env |
| 55 | + - name: Build and push |
| 56 | + uses: docker/build-push-action@v6 |
| 57 | + with: |
| 58 | + context: ./backend |
| 59 | + file: .docker/backend/Dockerfile |
| 60 | + push: ${{ github.event_name != 'pull_request' }} |
| 61 | + pull: true |
| 62 | + tags: | |
| 63 | + ksetcomp/jobfair-2022-backend:latest |
| 64 | + ksetcomp/jobfair-2022-backend:${{ github.sha }} |
| 65 | +
|
| 66 | + notify-watchtower: |
| 67 | + runs-on: [self-hosted] |
| 68 | + needs: [build-frontend, build-backend] |
| 69 | + steps: |
| 70 | + - name: Notify Watchtower |
| 71 | + run: | |
| 72 | + curl -sL -v \ |
| 73 | + --header 'Authorization: Bearer ${{ secrets.WATCHTOWER_TOKEN }}' \ |
| 74 | + "${{ vars.WATCHTOWER_URL }}/v1/update" |
0 commit comments