|
| 1 | +name: Build and Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - master |
| 8 | + schedule: |
| 9 | + # Rebuild every 15 days even sin cambios para mantener imágenes frescas |
| 10 | + - cron: "0 3 */15 * *" |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +jobs: |
| 14 | + build-desktop: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + permissions: |
| 17 | + contents: read |
| 18 | + packages: write |
| 19 | + outputs: |
| 20 | + run_build: ${{ steps.changes.outputs.run_build }} |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Detect changes for desktop |
| 26 | + id: changes |
| 27 | + run: | |
| 28 | + if [ "${GITHUB_EVENT_NAME:-}" = "schedule" ]; then |
| 29 | + echo "run_build=true" >> "$GITHUB_OUTPUT" |
| 30 | + echo "Scheduled run: forcing desktop build." |
| 31 | + exit 0 |
| 32 | + fi |
| 33 | + BASE_REF="${{ github.event.before }}" |
| 34 | + if [ -z "$BASE_REF" ] || ! git cat-file -e "$BASE_REF^{commit}" 2>/dev/null; then |
| 35 | + BASE_REF="HEAD^" |
| 36 | + fi |
| 37 | +
|
| 38 | + if git diff --quiet "$BASE_REF" HEAD -- Docker-Images/Desktop; then |
| 39 | + echo "run_build=false" >> "$GITHUB_OUTPUT" |
| 40 | + echo "No changes in Docker-Images/Desktop, skipping build." |
| 41 | + else |
| 42 | + echo "run_build=true" >> "$GITHUB_OUTPUT" |
| 43 | + echo "Changes detected in Docker-Images/Desktop, building image." |
| 44 | + fi |
| 45 | +
|
| 46 | + - name: Log in to GHCR |
| 47 | + if: steps.changes.outputs.run_build == 'true' |
| 48 | + uses: docker/login-action@v3 |
| 49 | + with: |
| 50 | + registry: ghcr.io |
| 51 | + username: ${{ github.actor }} |
| 52 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + |
| 54 | + - name: Extract metadata |
| 55 | + if: steps.changes.outputs.run_build == 'true' |
| 56 | + id: meta |
| 57 | + uses: docker/metadata-action@v5 |
| 58 | + with: |
| 59 | + images: ghcr.io/${{ github.repository_owner }}/coder-mks-desktop |
| 60 | + tags: | |
| 61 | + type=raw,value=latest |
| 62 | + type=sha |
| 63 | +
|
| 64 | + - name: Set up Docker Buildx |
| 65 | + if: steps.changes.outputs.run_build == 'true' |
| 66 | + uses: docker/setup-buildx-action@v3 |
| 67 | + |
| 68 | + - name: Build and push |
| 69 | + if: steps.changes.outputs.run_build == 'true' |
| 70 | + uses: docker/build-push-action@v5 |
| 71 | + with: |
| 72 | + context: Docker-Images/Desktop |
| 73 | + push: true |
| 74 | + platforms: linux/amd64 |
| 75 | + tags: ${{ steps.meta.outputs.tags }} |
| 76 | + labels: ${{ steps.meta.outputs.labels }} |
| 77 | + cache-from: type=gha,scope=coder-mks-desktop |
| 78 | + cache-to: type=gha,mode=max,scope=coder-mks-desktop |
| 79 | + build-args: | |
| 80 | + BUILDKIT_STEP_TIMEOUT=1800 |
| 81 | + sbom: false |
| 82 | + |
| 83 | + build-desktop-kde: |
| 84 | + runs-on: ubuntu-latest |
| 85 | + permissions: |
| 86 | + contents: read |
| 87 | + packages: write |
| 88 | + outputs: |
| 89 | + run_build: ${{ steps.changes.outputs.run_build }} |
| 90 | + steps: |
| 91 | + - name: Checkout |
| 92 | + uses: actions/checkout@v4 |
| 93 | + |
| 94 | + - name: Detect changes for desktop-kde |
| 95 | + id: changes |
| 96 | + run: | |
| 97 | + if [ "${GITHUB_EVENT_NAME:-}" = "schedule" ]; then |
| 98 | + echo "run_build=true" >> "$GITHUB_OUTPUT" |
| 99 | + echo "Scheduled run: forcing desktop-kde build." |
| 100 | + exit 0 |
| 101 | + fi |
| 102 | + BASE_REF="${{ github.event.before }}" |
| 103 | + if [ -z "$BASE_REF" ] || ! git cat-file -e "$BASE_REF^{commit}" 2>/dev/null; then |
| 104 | + BASE_REF="HEAD^" |
| 105 | + fi |
| 106 | +
|
| 107 | + if git diff --quiet "$BASE_REF" HEAD -- Docker-Images/Desktop-KDE; then |
| 108 | + echo "run_build=false" >> "$GITHUB_OUTPUT" |
| 109 | + echo "No changes in Docker-Images/Desktop-KDE, skipping build." |
| 110 | + else |
| 111 | + echo "run_build=true" >> "$GITHUB_OUTPUT" |
| 112 | + echo "Changes detected in Docker-Images/Desktop-KDE, building image." |
| 113 | + fi |
| 114 | +
|
| 115 | + - name: Log in to GHCR |
| 116 | + if: steps.changes.outputs.run_build == 'true' |
| 117 | + uses: docker/login-action@v3 |
| 118 | + with: |
| 119 | + registry: ghcr.io |
| 120 | + username: ${{ github.actor }} |
| 121 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 122 | + |
| 123 | + - name: Extract metadata |
| 124 | + if: steps.changes.outputs.run_build == 'true' |
| 125 | + id: meta |
| 126 | + uses: docker/metadata-action@v5 |
| 127 | + with: |
| 128 | + images: ghcr.io/${{ github.repository_owner }}/coder-mks-desktop-kde |
| 129 | + tags: | |
| 130 | + type=raw,value=latest |
| 131 | + type=sha |
| 132 | +
|
| 133 | + - name: Set up Docker Buildx |
| 134 | + if: steps.changes.outputs.run_build == 'true' |
| 135 | + uses: docker/setup-buildx-action@v3 |
| 136 | + |
| 137 | + - name: Build and push |
| 138 | + if: steps.changes.outputs.run_build == 'true' |
| 139 | + uses: docker/build-push-action@v5 |
| 140 | + with: |
| 141 | + context: Docker-Images/Desktop-KDE |
| 142 | + push: true |
| 143 | + platforms: linux/amd64 |
| 144 | + tags: ${{ steps.meta.outputs.tags }} |
| 145 | + labels: ${{ steps.meta.outputs.labels }} |
| 146 | + cache-from: type=gha,scope=coder-mks-desktop-kde |
| 147 | + cache-to: type=gha,mode=max,scope=coder-mks-desktop-kde |
| 148 | + build-args: | |
| 149 | + BUILDKIT_STEP_TIMEOUT=1800 |
| 150 | + sbom: false |
| 151 | + |
| 152 | + build: |
| 153 | + needs: [build-desktop, build-desktop-kde] |
| 154 | + runs-on: ubuntu-latest |
| 155 | + permissions: |
| 156 | + contents: read |
| 157 | + packages: write |
| 158 | + strategy: |
| 159 | + fail-fast: false |
| 160 | + matrix: |
| 161 | + include: |
| 162 | + - image_name: coder-mks-developer |
| 163 | + context: Docker-Images/Developer |
| 164 | + base_dep: desktop |
| 165 | + - image_name: coder-mks-design |
| 166 | + context: Docker-Images/Designer |
| 167 | + base_dep: desktop-kde |
| 168 | + - image_name: coder-mks-developer-android |
| 169 | + context: Docker-Images/DeveloperAndroid |
| 170 | + base_dep: desktop-kde |
| 171 | + steps: |
| 172 | + - name: Checkout |
| 173 | + uses: actions/checkout@v4 |
| 174 | + |
| 175 | + - name: Detect changes for image |
| 176 | + id: changes |
| 177 | + run: | |
| 178 | + if [ "${GITHUB_EVENT_NAME:-}" = "schedule" ]; then |
| 179 | + echo "run_build=true" >> "$GITHUB_OUTPUT" |
| 180 | + echo "Scheduled run: forcing build for ${{ matrix.image_name }}." |
| 181 | + exit 0 |
| 182 | + fi |
| 183 | + # If a base image rebuilt, force dependent images to rebuild |
| 184 | + if [ "${{ matrix.base_dep }}" = "desktop" ] && [ "${{ needs.build-desktop.outputs.run_build }}" = "true" ]; then |
| 185 | + echo "run_build=true" >> "$GITHUB_OUTPUT" |
| 186 | + echo "Desktop rebuilt; forcing build for ${{ matrix.image_name }}." |
| 187 | + exit 0 |
| 188 | + fi |
| 189 | + if [ "${{ matrix.base_dep }}" = "desktop-kde" ] && [ "${{ needs.build-desktop-kde.outputs.run_build }}" = "true" ]; then |
| 190 | + echo "run_build=true" >> "$GITHUB_OUTPUT" |
| 191 | + echo "Desktop-KDE rebuilt; forcing build for ${{ matrix.image_name }}." |
| 192 | + exit 0 |
| 193 | + fi |
| 194 | +
|
| 195 | + BASE_REF="${{ github.event.before }}" |
| 196 | + if [ -z "$BASE_REF" ] || ! git cat-file -e "$BASE_REF^{commit}" 2>/dev/null; then |
| 197 | + BASE_REF="HEAD^" |
| 198 | + fi |
| 199 | +
|
| 200 | + if git diff --quiet "$BASE_REF" HEAD -- "${{ matrix.context }}"; then |
| 201 | + echo "run_build=false" >> "$GITHUB_OUTPUT" |
| 202 | + echo "No changes in ${{ matrix.context }}, skipping build." |
| 203 | + else |
| 204 | + echo "run_build=true" >> "$GITHUB_OUTPUT" |
| 205 | + echo "Changes detected in ${{ matrix.context }}, building image." |
| 206 | + fi |
| 207 | +
|
| 208 | + - name: Log in to GHCR |
| 209 | + uses: docker/login-action@v3 |
| 210 | + if: steps.changes.outputs.run_build == 'true' |
| 211 | + with: |
| 212 | + registry: ghcr.io |
| 213 | + username: ${{ github.actor }} |
| 214 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 215 | + |
| 216 | + - name: Extract metadata |
| 217 | + id: meta |
| 218 | + uses: docker/metadata-action@v5 |
| 219 | + if: steps.changes.outputs.run_build == 'true' |
| 220 | + with: |
| 221 | + images: ghcr.io/${{ github.repository_owner }}/${{ matrix.image_name }} |
| 222 | + tags: | |
| 223 | + type=raw,value=latest |
| 224 | + type=sha |
| 225 | +
|
| 226 | + - name: Set up Docker Buildx |
| 227 | + uses: docker/setup-buildx-action@v3 |
| 228 | + if: steps.changes.outputs.run_build == 'true' |
| 229 | + |
| 230 | + - name: Build and push |
| 231 | + uses: docker/build-push-action@v5 |
| 232 | + if: steps.changes.outputs.run_build == 'true' |
| 233 | + with: |
| 234 | + context: ${{ matrix.context }} |
| 235 | + push: true |
| 236 | + platforms: linux/amd64 |
| 237 | + tags: ${{ steps.meta.outputs.tags }} |
| 238 | + labels: ${{ steps.meta.outputs.labels }} |
| 239 | + cache-from: type=gha,scope=${{ matrix.image_name }} |
| 240 | + cache-to: type=gha,mode=max,scope=${{ matrix.image_name }} |
| 241 | + build-args: | |
| 242 | + BUILDKIT_STEP_TIMEOUT=1800 |
| 243 | + sbom: false |
0 commit comments