reformat state.json #32
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: Mini-CD | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'backend/**' | |
| - 'runners/**' | |
| jobs: | |
| check-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| backend_changed: ${{ steps.detect.outputs.backend }} | |
| runners_changed: ${{ steps.detect.outputs.runners }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect changed components | |
| id: detect | |
| run: | | |
| CHANGED_FILES=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}") | |
| echo "Changed files:" | |
| echo "$CHANGED_FILES" | |
| if echo "$CHANGED_FILES" | grep -q '^backend/'; then | |
| echo "backend=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "backend=false" >> $GITHUB_OUTPUT | |
| fi | |
| if echo "$CHANGED_FILES" | grep -q '^runners/'; then | |
| echo "runners=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "runners=false" >> $GITHUB_OUTPUT | |
| fi | |
| build-and-push-backend: | |
| needs: check-changes | |
| if: needs.check-changes.outputs.backend_changed == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and push backend | |
| run: | | |
| IMAGE="${{ secrets.DOCKER_USERNAME }}/pipelinex:backend-latest" | |
| docker build -f backend/Dockerfile -t "$IMAGE" . | |
| docker push "$IMAGE" | |
| build-and-push-runners: | |
| needs: check-changes | |
| if: needs.check-changes.outputs.runners_changed == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and push runner | |
| run: | | |
| IMAGE="${{ secrets.DOCKER_USERNAME }}/pipelinex:java17-mvn3.9.12-latest" | |
| docker build -f runners/java17-maven3.9/Dockerfile -t "$IMAGE" runners | |
| docker push "$IMAGE" | |