|
| 1 | +name: Realse Version |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - dev |
| 8 | + paths: |
| 9 | + - 'app/**' |
| 10 | + - 'crawl/**' |
| 11 | + |
| 12 | +jobs: |
| 13 | + releaseGithub: |
| 14 | + if: github.ref == 'refs/heads/master' |
| 15 | + runs-on: ubuntu-22.04 |
| 16 | + permissions: |
| 17 | + contents: write |
| 18 | + pull-requests: write |
| 19 | + steps: |
| 20 | + - name: Bump version and push tag |
| 21 | + id: bump |
| 22 | + uses: mathieudutour/[email protected] |
| 23 | + with: |
| 24 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 25 | + default_bump: patch |
| 26 | + |
| 27 | + - name: Build Changelog |
| 28 | + id: github_release |
| 29 | + uses: mikepenz/release-changelog-builder-action@v5 |
| 30 | + env: |
| 31 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + fromTag: ${{ steps.bump.outputs.previous_tag }} |
| 33 | + toTag: ${{ steps.bump.outputs.new_tag }} |
| 34 | + |
| 35 | + - name: Create Release |
| 36 | + uses: softprops/action-gh-release@v2 |
| 37 | + with: |
| 38 | + body: ${{ steps.bump.outputs.changelog }} |
| 39 | + tag_name: ${{ steps.bump.outputs.new_tag }} |
| 40 | + |
| 41 | + releaseDockerWithDeployment: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - name: Checkout code |
| 45 | + uses: actions/checkout@v3 |
| 46 | + |
| 47 | + - name: Log in to DockerHub |
| 48 | + uses: docker/login-action@v2 |
| 49 | + with: |
| 50 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 51 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 52 | + |
| 53 | + - name: Build and Push Docker Image |
| 54 | + uses: docker/build-push-action@v5 |
| 55 | + with: |
| 56 | + context: . |
| 57 | + push: true |
| 58 | + tags: | |
| 59 | + ${{ secrets.DOCKER_USERNAME }}/devopsgpt-fastapi:${{ github.ref_name }} |
| 60 | +
|
| 61 | + - name: Deploying landing prod on the remote server |
| 62 | + if: github.ref == 'refs/heads/master' |
| 63 | + |
| 64 | + with: |
| 65 | + host: ${{ secrets.HOST }} |
| 66 | + username: ${{ secrets.HOST_USERNAME }} |
| 67 | + password: ${{ secrets.HOST_PASSWORD }} |
| 68 | + port: ${{ secrets.HOST_PORT }} |
| 69 | + script: docker compose -f devopsgpt-fastapi/docker-compose-fastapi.yml down fastapi_prod && docker compose -f devopsgpt-fastapi/docker-compose-fastapi.yml up -d --pull always fastapi_prod |
| 70 | + |
| 71 | + - name: Deploying landing dev on the remote server |
| 72 | + if: github.ref == 'refs/heads/dev' |
| 73 | + |
| 74 | + with: |
| 75 | + host: ${{ secrets.HOST }} |
| 76 | + username: ${{ secrets.HOST_USERNAME }} |
| 77 | + password: ${{ secrets.HOST_PASSWORD }} |
| 78 | + port: ${{ secrets.HOST_PORT }} |
| 79 | + script: docker compose -f devopsgpt-fastapi/docker-compose-fastapi.yml down fastapi_dev && docker compose -f devopsgpt-fastapi/docker-compose-fastapi.yml up -d --pull always fastapi_dev |
| 80 | + |
| 81 | + - name: Removing dangle images on the remote server |
| 82 | + |
| 83 | + with: |
| 84 | + host: ${{ secrets.HOST }} |
| 85 | + username: ${{ secrets.HOST_USERNAME }} |
| 86 | + password: ${{ secrets.HOST_PASSWORD }} |
| 87 | + port: ${{ secrets.HOST_PORT }} |
| 88 | + script: docker image prune -f |
0 commit comments