|
| 1 | +name: CI |
| 2 | + |
| 3 | +permissions: |
| 4 | + id-token: write # Required for signing |
| 5 | + contents: read |
| 6 | + packages: write |
| 7 | + attestations: write |
| 8 | + pages: write |
| 9 | + |
| 10 | +on: |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - master |
| 14 | + pull_request: |
| 15 | + branches: |
| 16 | + - master |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 20 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 21 | + |
| 22 | +env: |
| 23 | + IMAGE: ghcr.io/twogiants/console-functions-plugin |
| 24 | + |
| 25 | +jobs: |
| 26 | + # -------- |
| 27 | + # CHECKS |
| 28 | + # -------- |
| 29 | + checks: |
| 30 | + name: Lint and Test |
| 31 | + runs-on: ubuntu-latest |
| 32 | + timeout-minutes: 15 |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Setup Node.js |
| 37 | + uses: actions/setup-node@v4 |
| 38 | + with: |
| 39 | + node-version: "22" |
| 40 | + cache: yarn |
| 41 | + |
| 42 | + - name: Enable Corepack |
| 43 | + run: corepack enable |
| 44 | + |
| 45 | + - name: Install Dependencies |
| 46 | + run: yarn install --immutable |
| 47 | + |
| 48 | + - name: Lint |
| 49 | + run: yarn lint |
| 50 | + |
| 51 | + - name: Test |
| 52 | + run: yarn test |
| 53 | + |
| 54 | + # ----------- |
| 55 | + # BUILD IMAGE |
| 56 | + # ----------- |
| 57 | + build-image: |
| 58 | + name: Build Image |
| 59 | + needs: checks |
| 60 | + runs-on: ubuntu-latest |
| 61 | + timeout-minutes: 30 |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v4 |
| 64 | + - uses: docker/setup-qemu-action@v3 |
| 65 | + - uses: docker/setup-buildx-action@v3 |
| 66 | + |
| 67 | + - name: Build Image |
| 68 | + uses: docker/build-push-action@v6 |
| 69 | + env: |
| 70 | + SOURCE_DATE_EPOCH: 0 |
| 71 | + with: |
| 72 | + context: . |
| 73 | + push: false |
| 74 | + # Multi-arch is required for OCP. |
| 75 | + platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x |
| 76 | + cache-from: type=gha |
| 77 | + cache-to: type=gha,mode=max |
| 78 | + |
| 79 | + # ------------- |
| 80 | + # PUBLISH IMAGE |
| 81 | + # ------------- |
| 82 | + publish: |
| 83 | + name: Publish Image |
| 84 | + needs: build-image |
| 85 | + if: github.event_name == 'push' && github.ref == 'refs/heads/master' |
| 86 | + runs-on: ubuntu-latest |
| 87 | + timeout-minutes: 30 |
| 88 | + steps: |
| 89 | + - uses: actions/checkout@v4 |
| 90 | + - uses: docker/setup-qemu-action@v3 |
| 91 | + - uses: docker/setup-buildx-action@v3 |
| 92 | + |
| 93 | + - name: Login to GHCR |
| 94 | + uses: docker/login-action@v3 |
| 95 | + with: |
| 96 | + registry: ghcr.io |
| 97 | + username: ${{ github.actor }} |
| 98 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 99 | + |
| 100 | + - name: Build and Push Image |
| 101 | + id: build-and-push |
| 102 | + uses: docker/build-push-action@v6 |
| 103 | + env: |
| 104 | + SOURCE_DATE_EPOCH: 0 |
| 105 | + with: |
| 106 | + context: . |
| 107 | + push: true |
| 108 | + platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x |
| 109 | + tags: | |
| 110 | + ${{ env.IMAGE }}:latest |
| 111 | + ${{ env.IMAGE }}:sha-${{ github.sha }} |
| 112 | + cache-from: type=gha |
| 113 | + annotations: | |
| 114 | + index:org.opencontainers.image.description=Serverless Functions Console Plugin for OpenShift |
| 115 | + index:org.opencontainers.image.source=https://github.com/twoGiants/func-console |
| 116 | + index:org.opencontainers.image.vendor=https://github.com/twoGiants/func-console |
| 117 | + index:org.opencontainers.image.url=https://github.com/twoGiants/func-console/pkgs/container/console-functions-plugin |
| 118 | +
|
| 119 | + # Attestation is required for OCP. |
| 120 | + - name: Attest Build Provenance |
| 121 | + uses: actions/attest-build-provenance@v3 |
| 122 | + with: |
| 123 | + subject-name: ${{ env.IMAGE }} |
| 124 | + subject-digest: ${{ steps.build-and-push.outputs.digest }} |
| 125 | + push-to-registry: true |
| 126 | + |
| 127 | + # ------------ |
| 128 | + # DEPLOY PAGES |
| 129 | + # ------------ |
| 130 | + deploy-pages: |
| 131 | + name: Deploy Pages |
| 132 | + needs: publish |
| 133 | + runs-on: ubuntu-latest |
| 134 | + timeout-minutes: 5 |
| 135 | + environment: |
| 136 | + name: github-pages |
| 137 | + url: ${{ steps.deployment.outputs.page_url }} |
| 138 | + steps: |
| 139 | + - uses: actions/checkout@v4 |
| 140 | + |
| 141 | + - name: Setup Helm |
| 142 | + uses: azure/setup-helm@v4 |
| 143 | + |
| 144 | + - name: Generate deployment YAML |
| 145 | + run: | |
| 146 | + mkdir public |
| 147 | + helm template console-functions-plugin charts/openshift-console-plugin \ |
| 148 | + -n console-functions-plugin \ |
| 149 | + --set "plugin.image=${{ env.IMAGE }}:sha-${{ github.sha }}" \ |
| 150 | + > public/plugin.yaml |
| 151 | +
|
| 152 | + - name: Upload Pages artifact |
| 153 | + uses: actions/upload-pages-artifact@v3 |
| 154 | + with: |
| 155 | + path: ./public |
| 156 | + |
| 157 | + - name: Deploy to GitHub Pages |
| 158 | + id: deployment |
| 159 | + uses: actions/deploy-pages@v5 |
0 commit comments