Add readmes #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: Build image | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - 'main' | |
| paths-ignore: | |
| - '**/README.md' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| set-env: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| LATEST_TAG: ${{ steps.set.outputs.LATEST_TAG }} | |
| REGISTRY: ${{ steps.set.outputs.REGISTRY }} | |
| REGISTRY_USER: ${{ steps.set.outputs.REGISTRY_USER }} | |
| PLATFORMS: ${{ steps.set.outputs.PLATFORMS }} | |
| IMAGE_PATH: ${{ steps.set.outputs.IMAGE_PATH }} | |
| IMAGE_NAME: ${{ steps.set.outputs.IMAGE_NAME }} | |
| IMAGE_REF: ${{ steps.set.outputs.IMAGE_REF }} | |
| IS_SIGNED: ${{ steps.set.outputs.IS_SIGNED }} | |
| steps: | |
| - name: Set environment variables | |
| id: set | |
| run: | | |
| # Pick a latest tag based on the event type | |
| if [[ "${{ github.ref }}" != "refs/heads/${{ github.event.repository.default_branch }}" ]]; then | |
| echo "LATEST_TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "LATEST_TAG=latest" >> $GITHUB_OUTPUT | |
| fi | |
| REGISTRY=ghcr.io | |
| REGISTRY_USER=${{ github.actor }} | |
| IMAGE_PATH=${{ github.repository_owner }} | |
| IMAGE_NAME=${{ github.event.repository.name }} | |
| PLATFORMS="amd64" | |
| echo "REGISTRY=${REGISTRY}" >> $GITHUB_OUTPUT | |
| echo "REGISTRY_USER=${REGISTRY_USER}" >> $GITHUB_OUTPUT | |
| echo "IMAGE_PATH=${IMAGE_PATH}" >> $GITHUB_OUTPUT | |
| echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_OUTPUT | |
| echo "IMAGE_REF=${REGISTRY}/${IMAGE_PATH}/${IMAGE_NAME}" >> $GITHUB_OUTPUT | |
| echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_OUTPUT | |
| # This is a workaround so that the expansion of secrets.SIGNING_SECRET doesn't break the if statement | |
| SECRET=$(cat <<EOF | |
| ${{ secrets.SIGNING_SECRET }} | |
| EOF | |
| ) | |
| if [ -z "${SECRET}" ]; then | |
| echo "IS_SIGNED=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "IS_SIGNED=true" >> $GITHUB_OUTPUT | |
| fi | |
| build-image: | |
| name: Build image | |
| uses: AlmaLinux/desktop-bootc-ci/.github/workflows/build-image.yml@v4 | |
| needs: set-env | |
| with: | |
| containerfile: Dockerfile | |
| image-name: "${{ needs.set-env.outputs.IMAGE_NAME }}" | |
| previous-image: "${{ needs.set-env.outputs.IMAGE_REF }}:latest" | |
| upstream-public-key: atomic-desktop.pub | |
| platforms: ${{ needs.set-env.outputs.PLATFORMS }} | |
| skip-maximize-build-space: true | |
| image-path: ${{ needs.set-env.outputs.IMAGE_PATH }} | |
| REGISTRY: ${{ needs.set-env.outputs.REGISTRY }} | |
| REGISTRY_USER: ${{ needs.set-env.outputs.REGISTRY_USER }} | |
| secrets: | |
| REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SIGNING_SECRET: ${{ secrets.SIGNING_SECRET }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| test-image: | |
| name: Test image | |
| runs-on: ubuntu-latest | |
| needs: [set-env, build-image] | |
| env: | |
| IMAGE_REF: "${{ needs.build-image.outputs.image-ref }}@${{ needs.build-image.outputs.digest }}" | |
| steps: | |
| - name: Login to Container Registry | |
| run: echo ${{ secrets.GITHUB_TOKEN }} | podman login -u ${{ needs.set-env.outputs.REGISTRY_USER }} --password-stdin ${{ needs.set-env.outputs.REGISTRY }} | |
| - name: Test container | |
| run: | | |
| # Create a short script to test the image using heredoc | |
| cat << 'EOF' > /tmp/test.sh | |
| set -ex | |
| cat /etc/os-release | |
| bootc -V | |
| EOF | |
| podman run --rm \ | |
| -v /tmp/test.sh:/tmp/test.sh \ | |
| ${{ env.IMAGE_REF }} \ | |
| /bin/bash /tmp/test.sh | |
| promote-image: | |
| name: Promote image | |
| needs: [set-env, build-image, test-image] | |
| if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
| uses: AlmaLinux/desktop-bootc-ci/.github/workflows/retag-image.yml@v4 | |
| with: | |
| image: ${{ needs.build-image.outputs.image-ref }}@${{ needs.build-image.outputs.digest }} | |
| tag: | | |
| ${{ needs.set-env.outputs.LATEST_TAG }} | |
| ${{ needs.build-image.outputs.redhat-version-id }} | |
| ${{ needs.build-image.outputs.version }} | |
| REGISTRY: ${{ needs.set-env.outputs.REGISTRY }} | |
| REGISTRY_USER: ${{ needs.set-env.outputs.REGISTRY_USER }} | |
| secrets: | |
| REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| permissions: | |
| packages: write | |
| create-release: | |
| name: Create Release | |
| needs: [set-env, build-image, test-image, promote-image] | |
| if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
| uses: AlmaLinux/desktop-bootc-ci/.github/workflows/create-release.yml@v4 | |
| with: | |
| image-name: "${{ needs.set-env.outputs.IMAGE_NAME }}" | |
| version: ${{ needs.build-image.outputs.version }} | |
| pretty-version: ${{ needs.build-image.outputs.redhat-version-id }} | |
| latest-image-ref: "${{ needs.build-image.outputs.image-ref }}:${{ needs.set-env.outputs.LATEST_TAG }}" | |
| permissions: | |
| contents: write |