Extended rules popup #104
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: "Docker build, push and deploy" | |
| on: | |
| push: | |
| branches: [master] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build and push Docker image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 10 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ secrets.GH_USERNAME }} | |
| password: ${{ secrets.GH_ACCESS_TOKEN }} | |
| - name: Prepare version info | |
| run: | | |
| echo "LATEST_COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
| - name: Write version file | |
| run: echo "${{ env.LATEST_COMMIT_SHA }}" > version.txt | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push Docker images | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: | | |
| ghcr.io/studentiunimi/website:${{ env.LATEST_COMMIT_SHA }} | |
| ghcr.io/studentiunimi/website:latest | |
| deploy: | |
| name: Deploy swarm service | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Send Portainer webhook | |
| run: curl -X POST "${{ secrets.WEBSITE_DEPLOY_URL }}" |