queue: improve queue config #43
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 Deploy | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - 'main' | |
| # disable staging build | |
| # - 'staging' | |
| tags: | |
| - 'v*' | |
| # pull_request: | |
| # branches: | |
| # - 'main' | |
| # disable staging build | |
| # - 'staging' | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| target: [app, queue, scheduler] | |
| outputs: | |
| branch: ${{ github.ref_name }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Extract metadata (tags, labels) | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ghcr.io/${{ github.repository_owner }}/cncnet-ladder-${{ matrix.target }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=raw,value=staging,enable=${{ github.ref == 'refs/heads/staging' }} | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push image (${{ matrix.target }}) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./docker/frankenphp/Dockerfile | |
| target: ${{ matrix.target }} | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| # cache not available for us | |
| # cache-from: type=gha,scope=${{ matrix.target }} | |
| # cache-to: type=gha,mode=max,scope=${{ matrix.target }} | |
| deploy: | |
| needs: build-and-push | |
| if: > | |
| github.event_name != 'pull_request' && | |
| (github.ref_name == 'main') | |
| # disable deployment to staging | |
| # || github.ref_name == 'staging' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set deployment variables | |
| id: vars | |
| run: | | |
| if [[ "${{ github.ref_name }}" == "staging" ]]; then | |
| echo "target_dir=~/ladder-staging-new" >> "$GITHUB_OUTPUT" | |
| echo "compose_file=docker-compose.yml" >> "$GITHUB_OUTPUT" | |
| elif [[ "${{ github.ref_name }}" == "main" ]]; then | |
| echo "target_dir=~/ladder-new" >> "$GITHUB_OUTPUT" | |
| echo "compose_file=docker-compose.yml" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Unsupported branch" | |
| exit 1 | |
| fi | |
| - name: Copy compose file to server | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USER }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| source: ${{ steps.vars.outputs.compose_file }} | |
| target: ${{ steps.vars.outputs.target_dir }} | |
| - name: Stop and start app on server | |
| uses: appleboy/ssh-action@v1.2.1 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USER }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script: | | |
| cd ${{ steps.vars.outputs.target_dir }} | |
| echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| docker compose -f ${{ steps.vars.outputs.compose_file }} down | |
| docker compose -f ${{ steps.vars.outputs.compose_file }} pull | |
| rm -rf cache/* | |
| docker compose -f ${{ steps.vars.outputs.compose_file }} up -d |