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: Build django (production) | |
| env: | |
| DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USERNAME }} | |
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
| DOCKER_TAG: ${{ github.event.pull_request.title }} | |
| PR_BODY: ${{ github.event.pull_request.body }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| ACTIONS_STEP_DEBUG: true | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - main | |
| jobs: | |
| Build: | |
| if: github.event.pull_request.merged == true | |
| runs-on: self-hosted-stage | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Get metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: 5scontrol/django | |
| tags: | | |
| prod-${{env.DOCKER_TAG}} | |
| prod-latest | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ env.DOCKERHUB_USERNAME }} | |
| password: ${{ env.DOCKERHUB_TOKEN }} | |
| continue-on-error: false | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push Docker images | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=registry,ref=5scontrol/django:prod-cache | |
| cache-to: type=registry,ref=5scontrol/django:prod-cache,mode=max | |
| continue-on-error: false | |
| env: | |
| DOCKER_BUILDKIT: 1 | |
| CreateRelease: | |
| runs-on: self-hosted-stage | |
| needs: Build | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Create a GitHub release | |
| uses: actions/create-release@v1 | |
| id: create_release | |
| with: | |
| tag_name: 'v${{ env.DOCKER_TAG }}' | |
| release_name: 'Release v${{ env.DOCKER_TAG }}' | |
| body: ${{ env.PR_BODY }} | |
| draft: false | |
| prerelease: false |