|
| 1 | +--- |
| 2 | +# ba0fde3d-bee7-4307-b97b-17d0d20aff50 |
| 3 | +name: Build image |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - 'main' |
| 9 | + paths-ignore: |
| 10 | + - '**/README.md' |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +jobs: |
| 18 | + set-env: |
| 19 | + if: github.repository != 'AlmaLinux/atomic-respin-template' |
| 20 | + runs-on: ubuntu-latest |
| 21 | + outputs: |
| 22 | + LATEST_TAG: ${{ steps.set.outputs.LATEST_TAG }} |
| 23 | + REGISTRY: ${{ steps.set.outputs.REGISTRY }} |
| 24 | + REGISTRY_USER: ${{ steps.set.outputs.REGISTRY_USER }} |
| 25 | + PLATFORMS: ${{ steps.set.outputs.PLATFORMS }} |
| 26 | + IMAGE_PATH: ${{ steps.set.outputs.IMAGE_PATH }} |
| 27 | + IMAGE_NAME: ${{ steps.set.outputs.IMAGE_NAME }} |
| 28 | + IMAGE_REF: ${{ steps.set.outputs.IMAGE_REF }} |
| 29 | + IS_SIGNED: ${{ steps.set.outputs.IS_SIGNED }} |
| 30 | + steps: |
| 31 | + - name: Checkout github actions |
| 32 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 33 | + |
| 34 | + - name: Set environment variables |
| 35 | + uses: ./.github/actions/config |
| 36 | + id: set |
| 37 | + with: |
| 38 | + SIGNING_SECRET: ${{ secrets.SIGNING_SECRET }} |
| 39 | + |
| 40 | + build-image: |
| 41 | + name: Build image |
| 42 | + uses: AlmaLinux/atomic-ci/.github/workflows/build-image.yml@v6 |
| 43 | + needs: set-env |
| 44 | + with: |
| 45 | + containerfile: Dockerfile |
| 46 | + image-name: "${{ needs.set-env.outputs.IMAGE_NAME }}" |
| 47 | + previous-image: "${{ needs.set-env.outputs.IMAGE_REF }}:latest" |
| 48 | + upstream-public-key: atomic-desktop.pub |
| 49 | + platforms: ${{ needs.set-env.outputs.PLATFORMS }} |
| 50 | + skip-maximize-build-space: true |
| 51 | + image-path: ${{ needs.set-env.outputs.IMAGE_PATH }} |
| 52 | + REGISTRY: ${{ needs.set-env.outputs.REGISTRY }} |
| 53 | + REGISTRY_USER: ${{ needs.set-env.outputs.REGISTRY_USER }} |
| 54 | + secrets: |
| 55 | + REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + SIGNING_SECRET: ${{ secrets.SIGNING_SECRET }} |
| 57 | + permissions: |
| 58 | + contents: read |
| 59 | + packages: write |
| 60 | + id-token: write |
| 61 | + |
| 62 | + test-image: |
| 63 | + name: Test image |
| 64 | + runs-on: ubuntu-latest |
| 65 | + needs: [set-env, build-image] |
| 66 | + |
| 67 | + env: |
| 68 | + IMAGE_REF: "${{ needs.build-image.outputs.image-ref }}@${{ needs.build-image.outputs.digest }}" |
| 69 | + |
| 70 | + steps: |
| 71 | + - name: Login to Container Registry |
| 72 | + run: echo ${{ secrets.GITHUB_TOKEN }} | podman login -u ${{ needs.set-env.outputs.REGISTRY_USER }} --password-stdin ${{ needs.set-env.outputs.REGISTRY }} |
| 73 | + |
| 74 | + - name: Test container |
| 75 | + run: | |
| 76 | + # Create a short script to test the image using heredoc |
| 77 | + cat << 'EOF' > /tmp/test.sh |
| 78 | + set -ex |
| 79 | +
|
| 80 | + cat /etc/os-release |
| 81 | + bootc -V |
| 82 | + EOF |
| 83 | +
|
| 84 | + podman run --rm \ |
| 85 | + -v /tmp/test.sh:/tmp/test.sh \ |
| 86 | + ${{ env.IMAGE_REF }} \ |
| 87 | + /bin/bash /tmp/test.sh |
| 88 | +
|
| 89 | + promote-image: |
| 90 | + name: Promote image |
| 91 | + needs: [set-env, build-image, test-image] |
| 92 | + if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} |
| 93 | + uses: AlmaLinux/atomic-ci/.github/workflows/retag-image.yml@v6 |
| 94 | + with: |
| 95 | + image: ${{ needs.build-image.outputs.image-ref }}@${{ needs.build-image.outputs.digest }} |
| 96 | + tag: | |
| 97 | + ${{ needs.set-env.outputs.LATEST_TAG }} |
| 98 | + ${{ needs.build-image.outputs.redhat-version-id }} |
| 99 | + ${{ needs.build-image.outputs.version }} |
| 100 | + REGISTRY: ${{ needs.set-env.outputs.REGISTRY }} |
| 101 | + REGISTRY_USER: ${{ needs.set-env.outputs.REGISTRY_USER }} |
| 102 | + secrets: |
| 103 | + REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 104 | + permissions: |
| 105 | + packages: write |
| 106 | + |
| 107 | + create-release: |
| 108 | + name: Create Release |
| 109 | + needs: [set-env, build-image, test-image, promote-image] |
| 110 | + if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} |
| 111 | + uses: AlmaLinux/atomic-ci/.github/workflows/create-release.yml@v6 |
| 112 | + with: |
| 113 | + image-name: "${{ needs.set-env.outputs.IMAGE_NAME }}" |
| 114 | + version: ${{ needs.build-image.outputs.version }} |
| 115 | + pretty-version: ${{ needs.build-image.outputs.redhat-version-id }} |
| 116 | + latest-image-ref: "${{ needs.build-image.outputs.image-ref }}:${{ needs.set-env.outputs.LATEST_TAG }}" |
| 117 | + permissions: |
| 118 | + contents: write |
0 commit comments