|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + |
| 9 | +env: |
| 10 | + REGISTRY: ghcr.io |
| 11 | + IMAGE_NAME_OPERATOR: ${{ github.repository }}/operator |
| 12 | + IMAGE_NAME_WEBUI: ${{ github.repository }}/webui |
| 13 | + |
| 14 | +jobs: |
| 15 | + build-images: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: read |
| 19 | + packages: write |
| 20 | + outputs: |
| 21 | + operator-image: ${{ steps.meta-operator.outputs.tags }} |
| 22 | + webui-image: ${{ steps.meta-webui.outputs.tags }} |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Log in to Container Registry |
| 29 | + uses: docker/login-action@v3 |
| 30 | + with: |
| 31 | + registry: ${{ env.REGISTRY }} |
| 32 | + username: ${{ github.actor }} |
| 33 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + |
| 35 | + - name: Extract metadata for operator |
| 36 | + id: meta-operator |
| 37 | + uses: docker/metadata-action@v5 |
| 38 | + with: |
| 39 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_OPERATOR }} |
| 40 | + tags: | |
| 41 | + type=ref,event=branch |
| 42 | + type=ref,event=pr |
| 43 | + type=semver,pattern={{version}} |
| 44 | + type=semver,pattern={{major}}.{{minor}} |
| 45 | + type=raw,value=latest,enable={{is_default_branch}} |
| 46 | +
|
| 47 | + - name: Build and push operator image |
| 48 | + uses: docker/build-push-action@v5 |
| 49 | + with: |
| 50 | + context: . |
| 51 | + file: ./Dockerfile |
| 52 | + push: true |
| 53 | + tags: ${{ steps.meta-operator.outputs.tags }} |
| 54 | + labels: ${{ steps.meta-operator.outputs.labels }} |
| 55 | + |
| 56 | + - name: Extract metadata for webui |
| 57 | + id: meta-webui |
| 58 | + uses: docker/metadata-action@v5 |
| 59 | + with: |
| 60 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_WEBUI }} |
| 61 | + tags: | |
| 62 | + type=ref,event=branch |
| 63 | + type=ref,event=pr |
| 64 | + type=semver,pattern={{version}} |
| 65 | + type=semver,pattern={{major}}.{{minor}} |
| 66 | + type=raw,value=latest,enable={{is_default_branch}} |
| 67 | +
|
| 68 | + - name: Build and push webui image |
| 69 | + uses: docker/build-push-action@v5 |
| 70 | + with: |
| 71 | + context: ./web |
| 72 | + file: ./web/Dockerfile |
| 73 | + push: true |
| 74 | + tags: ${{ steps.meta-webui.outputs.tags }} |
| 75 | + labels: ${{ steps.meta-webui.outputs.labels }} |
| 76 | + |
| 77 | + release-helm-chart: |
| 78 | + needs: build-images |
| 79 | + if: github.ref == 'refs/heads/main' |
| 80 | + permissions: |
| 81 | + contents: write |
| 82 | + pages: write |
| 83 | + id-token: write |
| 84 | + runs-on: ubuntu-latest |
| 85 | + |
| 86 | + steps: |
| 87 | + - name: Checkout |
| 88 | + uses: actions/checkout@v4 |
| 89 | + with: |
| 90 | + fetch-depth: 0 |
| 91 | + |
| 92 | + - name: Configure Git |
| 93 | + run: | |
| 94 | + git config user.name "$GITHUB_ACTOR" |
| 95 | + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" |
| 96 | +
|
| 97 | + - name: Install Helm |
| 98 | + uses: azure/setup-helm@v4 |
| 99 | + with: |
| 100 | + version: '3.14.0' |
| 101 | + |
| 102 | + - name: Run chart-releaser |
| 103 | + uses: helm/chart-releaser-action@v1.6.0 |
| 104 | + env: |
| 105 | + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 106 | + with: |
| 107 | + charts_dir: helm |
| 108 | + |
| 109 | + - name: Update README on gh-pages |
| 110 | + run: | |
| 111 | + # Switch to gh-pages branch and pull latest changes |
| 112 | + git checkout gh-pages |
| 113 | + git pull origin gh-pages |
| 114 | + |
| 115 | + # Copy README, docs, and index.html from main branch |
| 116 | + git checkout main -- README.md |
| 117 | + git checkout main -- docs/ |
| 118 | + git checkout main -- index.html |
| 119 | + |
| 120 | + # Commit and push if there are changes |
| 121 | + git add README.md docs/ index.html |
| 122 | + if git diff --staged --quiet; then |
| 123 | + echo "No changes to README or docs" |
| 124 | + else |
| 125 | + git commit -m "Update README and docs from main branch" |
| 126 | + git push origin gh-pages |
| 127 | + fi |
0 commit comments