feat: improve service management + fix prod issue with pino logs (#29) #6
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 and Push Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'apps/web/package.json' | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: seastackapp/seastack | |
| jobs: | |
| check-version-change: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| outputs: | |
| version_changed: ${{ steps.check.outputs.changed }} | |
| new_version: ${{ steps.get_version.outputs.version }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4.2.2 | |
| with: | |
| fetch-depth: 2 | |
| - name: Get current version | |
| id: get_version | |
| run: | | |
| VERSION=$(jq -r '.version' apps/web/package.json) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Current version: $VERSION" | |
| - name: Get previous version | |
| id: get_prev_version | |
| run: | | |
| if git show HEAD^1:apps/web/package.json > /dev/null 2>&1; then | |
| PREV_VERSION=$(git show HEAD^1:apps/web/package.json | jq -r '.version') | |
| else | |
| PREV_VERSION="none" | |
| fi | |
| echo "prev_version=$PREV_VERSION" >> $GITHUB_OUTPUT | |
| echo "Previous version: $PREV_VERSION" | |
| - name: Check if version changed | |
| id: check | |
| run: | | |
| CURRENT="${{ steps.get_version.outputs.version }}" | |
| PREVIOUS="${{ steps.get_prev_version.outputs.prev_version }}" | |
| if [ "$CURRENT" != "$PREVIOUS" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "Version changed from $PREVIOUS to $CURRENT" | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "Version did not change" | |
| fi | |
| build-and-push: | |
| needs: check-version-change | |
| if: needs.check-version-change.outputs.version_changed == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4.2.2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3.7.1 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3.3.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6.10.0 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.check-version-change.outputs.new_version }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |