chore: update deps #24
Workflow file for this run
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: Deploy to prod when tag | |
| on: | |
| push: | |
| tags: | |
| - '*' | |
| jobs: | |
| bump-version: | |
| name: Bump version to ${{ github.ref_name }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Bump version in pyproject.toml and uv.lock to ${{ github.ref_name }} | |
| run: | | |
| sed -i 's/^ *version.*=.*"\([^"]*\)".*/version = "${{ github.ref_name }}"/' ./pyproject.toml | |
| uv lock | |
| - name: Commit and push updated pyproject.toml | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| branch: main | |
| commit_message: "chore: bump version to ${{ github.ref_name }}" | |
| commit_user_name: Adrien Carpentier | |
| commit_user_email: [email protected] | |
| commit_author: Adrien Carpentier <[email protected]> | |
| build-and-push: | |
| name: Build and push Docker image to ghcr.io/${{ github.repository }} | |
| needs: bump-version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image to ghcr.io/${{ github.repository }} | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository }}:latest | |
| ghcr.io/${{ github.repository }}:${{ github.ref_name }} | |
| - name: Verify image exists in registry | |
| run: | | |
| docker pull ghcr.io/${{ github.repository }}:${{ github.ref_name }} | |
| docker image inspect ghcr.io/${{ github.repository }}:${{ github.ref_name }} | |
| deploy: | |
| name: Deploy ${{ github.ref_name }} on prod | |
| needs: build-and-push | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Execute server commands for deploy | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USER }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script: | | |
| set -e # Exit on any error | |
| # Ensure directory exists | |
| mkdir -p /home/www/word-generator-api | |
| cd /home/www/word-generator-api | |
| # Clone or update the repository for configuration files | |
| if [ -d .git ]; then | |
| git fetch | |
| git reset --hard origin/main | |
| else | |
| git clone https://github.com/bolinocroustibat/word-generator-api.git . | |
| fi | |
| # Login to GitHub Container Registry | |
| echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| # Set the image tag | |
| export TAG="${{ github.ref_name }}" | |
| # Pull the new Docker images | |
| docker compose pull | |
| # Restart services | |
| docker compose down --remove-orphans | |
| docker compose up -d | |
| - name: Checkout repository for Sentry | |
| uses: actions/checkout@v4 | |
| - name: Create Sentry release | |
| uses: getsentry/action-release@v3 | |
| env: | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| SENTRY_ORG: "adrien-carpentier" | |
| SENTRY_PROJECT: "word-generator-api" | |
| with: | |
| environment: production | |
| release: ${{ github.ref_name }} |