|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, master] |
| 6 | + pull_request: |
| 7 | + branches: [main, master] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + test: |
| 12 | + name: Unit Tests |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Set up Go |
| 19 | + uses: actions/setup-go@v5 |
| 20 | + with: |
| 21 | + go-version: "1.23" |
| 22 | + |
| 23 | + - name: Run tests |
| 24 | + run: make test |
| 25 | + |
| 26 | + lint-ui: |
| 27 | + name: Lint UI |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - name: Checkout code |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Set up Node.js |
| 34 | + uses: actions/setup-node@v4 |
| 35 | + with: |
| 36 | + node-version: "16" |
| 37 | + cache: yarn |
| 38 | + cache-dependency-path: ui/yarn.lock |
| 39 | + |
| 40 | + - name: Install dependencies |
| 41 | + working-directory: ui |
| 42 | + run: yarn |
| 43 | + |
| 44 | + - name: Lint |
| 45 | + working-directory: ui |
| 46 | + run: yarn run lint --no-fix |
| 47 | + |
| 48 | + docker: |
| 49 | + name: Build Docker Image |
| 50 | + needs: [test, lint-ui] |
| 51 | + runs-on: ubuntu-latest |
| 52 | + permissions: |
| 53 | + contents: read |
| 54 | + packages: write |
| 55 | + steps: |
| 56 | + - name: Checkout code |
| 57 | + uses: actions/checkout@v4 |
| 58 | + with: |
| 59 | + fetch-depth: 0 |
| 60 | + |
| 61 | + - name: Set up QEMU |
| 62 | + uses: docker/setup-qemu-action@v3 |
| 63 | + |
| 64 | + - name: Set up Docker Buildx |
| 65 | + uses: docker/setup-buildx-action@v3 |
| 66 | + |
| 67 | + - name: Login to GitHub Container Registry |
| 68 | + if: github.event_name != 'pull_request' |
| 69 | + uses: docker/login-action@v3 |
| 70 | + with: |
| 71 | + registry: ghcr.io |
| 72 | + username: ${{ github.actor }} |
| 73 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + |
| 75 | + - name: Login to Docker Hub |
| 76 | + if: github.event_name != 'pull_request' |
| 77 | + uses: docker/login-action@v3 |
| 78 | + with: |
| 79 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 80 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 81 | + |
| 82 | + - name: Extract metadata |
| 83 | + id: meta |
| 84 | + uses: docker/metadata-action@v5 |
| 85 | + with: |
| 86 | + images: | |
| 87 | + ghcr.io/${{ github.repository }} |
| 88 | + keelhq/keel |
| 89 | + tags: | |
| 90 | + type=ref,event=branch |
| 91 | + type=ref,event=pr |
| 92 | + type=semver,pattern={{version}} |
| 93 | + type=semver,pattern={{major}}.{{minor}} |
| 94 | + type=sha,format=long |
| 95 | + type=raw,value=latest,enable={{is_default_branch}} |
| 96 | +
|
| 97 | + - name: Build and push |
| 98 | + uses: docker/build-push-action@v6 |
| 99 | + with: |
| 100 | + context: . |
| 101 | + platforms: linux/amd64,linux/arm64 |
| 102 | + push: ${{ github.event_name != 'pull_request' }} |
| 103 | + tags: ${{ steps.meta.outputs.tags }} |
| 104 | + labels: ${{ steps.meta.outputs.labels }} |
| 105 | + cache-from: type=gha |
| 106 | + cache-to: type=gha,mode=max |
| 107 | + |
| 108 | + - name: Build for PR validation |
| 109 | + if: github.event_name == 'pull_request' |
| 110 | + uses: docker/build-push-action@v6 |
| 111 | + with: |
| 112 | + context: . |
| 113 | + platforms: linux/amd64,linux/arm64 |
| 114 | + push: false |
| 115 | + cache-from: type=gha |
| 116 | + cache-to: type=gha,mode=max |
0 commit comments