|
| 1 | +--- |
| 2 | +name: deck image |
| 3 | + |
| 4 | +on: |
| 5 | + schedule: |
| 6 | + - cron: '0 3 * * *' |
| 7 | + push: |
| 8 | + branches: ["main"] |
| 9 | + paths: |
| 10 | + - Containerfile.deck |
| 11 | + - build/** |
| 12 | + - system/** |
| 13 | + |
| 14 | +env: |
| 15 | + DEFAULT_TAG: "latest" |
| 16 | + IMAGE_NAME: ${{ github.event.repository.name }}-deck |
| 17 | + IMAGE_DESC: "Customized image of bazzite" |
| 18 | + IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}" |
| 19 | + REGISTRY: ghcr.io |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + runs-on: ubuntu-24.04 |
| 24 | + permissions: |
| 25 | + contents: read |
| 26 | + packages: write |
| 27 | + id-token: write |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: prepare environment |
| 31 | + run: | |
| 32 | + echo "IMAGE_REGISTRY=${IMAGE_REGISTRY,,}" >> "${GITHUB_ENV}" |
| 33 | + echo "IMAGE_NAME=${IMAGE_NAME,,}" >> "${GITHUB_ENV}" |
| 34 | +
|
| 35 | + - name: checkout |
| 36 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
| 37 | + |
| 38 | + - name: mount btrfs for podman storage |
| 39 | + id: container-storage-action |
| 40 | + uses: ublue-os/container-storage-action@911baca08baf30c8654933e9e9723cb399892140 |
| 41 | + continue-on-error: true |
| 42 | + with: |
| 43 | + target-dir: /var/lib/containers |
| 44 | + mount-opts: compress-force=zstd:2 |
| 45 | + |
| 46 | + - name: get current date |
| 47 | + id: date |
| 48 | + run: | |
| 49 | + # shellcheck disable=SC1001 |
| 50 | + echo "date=$(date -u +%Y\-%m\-%d\T%H\:%M\:%S\Z)" >> "${GITHUB_OUTPUT}" |
| 51 | +
|
| 52 | + - name: metadata |
| 53 | + uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # v5 |
| 54 | + id: metadata |
| 55 | + with: |
| 56 | + tags: | |
| 57 | + type=schedule,pattern={{date 'YYYYMMDD'}} |
| 58 | + type=raw,value=latest |
| 59 | + labels: | |
| 60 | + org.opencontainers.image.created=${{ steps.date.outputs.date }} |
| 61 | + org.opencontainers.image.description=${{ env.IMAGE_DESC }} |
| 62 | + org.opencontainers.image.documentation=https://raw.githubusercontent.com/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}/${{ github.sha }}/README.md |
| 63 | + org.opencontainers.image.source=https://github.com/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}/blob/${{ github.sha }}/Containerfile.deck |
| 64 | + org.opencontainers.image.title=${{ env.IMAGE_NAME }} |
| 65 | + org.opencontainers.image.url=https://github.com/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}/tree/${{ github.sha }} |
| 66 | + org.opencontainers.image.vendor=${{ github.repository_owner }} |
| 67 | + org.opencontainers.image.licenses=MIT |
| 68 | + containers.bootc=1 |
| 69 | +
|
| 70 | + - name: free space |
| 71 | + run: | |
| 72 | + cd /opt |
| 73 | + find . -maxdepth 1 -mindepth 1 '!' -path ./containerd '!' -path ./actionarchivecache '!' -path ./runner '!' -path ./runner-cache -exec rm -rf '{}' ';' |
| 74 | +
|
| 75 | + - name: build image |
| 76 | + id: build_image |
| 77 | + uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2 |
| 78 | + with: |
| 79 | + containerfiles: | |
| 80 | + ./Containerfile.deck |
| 81 | + image: ${{ env.IMAGE_NAME }} |
| 82 | + tags: ${{ steps.metadata.outputs.tags }} |
| 83 | + labels: ${{ steps.metadata.outputs.labels }} |
| 84 | + oci: false |
| 85 | + |
| 86 | + - name: ghcr login |
| 87 | + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3 |
| 88 | + if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) |
| 89 | + with: |
| 90 | + registry: ghcr.io |
| 91 | + username: ${{ github.actor }} |
| 92 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + |
| 94 | + - name: push image |
| 95 | + uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2 |
| 96 | + if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) |
| 97 | + id: push |
| 98 | + env: |
| 99 | + REGISTRY_USER: ${{ github.actor }} |
| 100 | + REGISTRY_PASSWORD: ${{ github.token }} |
| 101 | + with: |
| 102 | + registry: ${{ env.IMAGE_REGISTRY }} |
| 103 | + image: ${{ env.IMAGE_NAME }} |
| 104 | + tags: ${{ steps.metadata.outputs.tags }} |
| 105 | + username: ${{ env.REGISTRY_USER }} |
| 106 | + password: ${{ env.REGISTRY_PASSWORD }} |
| 107 | + |
| 108 | + - name: install cosign |
| 109 | + uses: sigstore/cosign-installer@d7543c93d881b35a8faa02e8e3605f69b7a1ce62 # v3.10.0 |
| 110 | + if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) |
| 111 | + |
| 112 | + - name: sign image |
| 113 | + if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) |
| 114 | + run: | |
| 115 | + IMAGE_FULL="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}" |
| 116 | + cosign sign -y --key env://COSIGN_PRIVATE_KEY "$IMAGE_FULL@$DIGEST" |
| 117 | + env: |
| 118 | + DIGEST: ${{ steps.push.outputs.digest }} |
| 119 | + COSIGN_EXPERIMENTAL: false |
| 120 | + COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }} |
0 commit comments