company 분리 #2
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 Zavod UI | |
| on: | |
| workflow_dispatch: {} | |
| push: | |
| paths: | |
| - 'ui/**' | |
| pull_request: | |
| paths: | |
| - 'ui/**' | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_DB: test | |
| POSTGRES_USER: testuser | |
| POSTGRES_PASSWORD: testpass | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd="pg_isready -U testuser -d test" --health-interval=5s --health-timeout=5s --health-retries=10 | |
| defaults: | |
| run: | |
| working-directory: ui | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 24 | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run Jest tests | |
| run: npm test | |
| docker: | |
| if: | | |
| (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && | |
| (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| needs: [test] | |
| outputs: | |
| digest: ${{ steps.build.outputs.digest }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/opensanctions/zavod-ui | |
| tags: | | |
| type=ref,event=branch | |
| type=raw,value=${{ github.ref == 'refs/heads/main' && 'prod' || 'test' }} | |
| type=raw,value=latest | |
| - name: Set build date | |
| run: echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV | |
| - name: Get git revision | |
| id: gitrev | |
| run: echo "GIT_REVISION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| install: true | |
| - name: Login to Github Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push release | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| env: | |
| BUILD_DATE: ${{ env.BUILD_DATE }} | |
| with: | |
| context: ui | |
| pull: true | |
| push: true | |
| build-args: | | |
| BUILD_DATE=${{ env.BUILD_DATE }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| dispatch: | |
| if: | | |
| (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && | |
| (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') | |
| runs-on: ubuntu-latest | |
| needs: [docker] | |
| steps: | |
| - name: Dispatch add-on build | |
| uses: peter-evans/repository-dispatch@5fc4efd1a4797ddb68ffd0714a238564e4cc0e6f # v3 | |
| with: | |
| token: ${{ secrets.OPERATIONS_PAT }} | |
| repository: opensanctions/operations | |
| event-type: release | |
| client-payload: |- | |
| { | |
| "environment": "${{ github.ref == 'refs/heads/main' && 'prod' || 'test' }}", | |
| "image_version": "@${{ needs.docker.outputs.digest }}" | |
| } |