diff --git a/.github/actions/shared-steps/action.yml b/.github/actions/shared-steps/action.yml index 9a01ff3..1bcc792 100644 --- a/.github/actions/shared-steps/action.yml +++ b/.github/actions/shared-steps/action.yml @@ -27,6 +27,7 @@ runs: echo "CLEAN_ARCH=${ARCH//\//_}" >> "$GITHUB_ENV" - name: Log in to registry + if: github.event_name != 'pull_request' shell: bash run: sudo podman login ${{ inputs.IMAGE_REGISTRY }} -u ${{ inputs.REGISTRY_USER }} -p ${{ inputs.REGISTRY_PASSWORD }} @@ -39,6 +40,9 @@ runs: # 100 - updates available # 125 - tag/platform not found # 127 - command not found + if [ "${{ github.event_name }}" != "pull_request" ]; then + exit 100 + fi res=0 sudo podman run ${{ env.VARIANT }} --quiet --rm ${{ inputs.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.VERSION_MAJOR }} dnf check-update || res=$? echo "res=${res}" >> "$GITHUB_ENV" @@ -101,6 +105,21 @@ runs: echo "image-id=sha256:$(sudo podman image inspect ${{ env.IMAGE_NAME }} -f "{{.Id}}")" >> $GITHUB_OUTPUT + - name: Build Image Tars + id: tars + if: github.event_name == 'pull_request' + shell: bash + env: + IMAGE_ID: ${{ steps.rechunk.outputs.image-id }} + run: | + sudo podman tag \ + ${{ env.IMAGE_ID }} \ + localhost/${{ env.IMAGE_NAME }}:${{ inputs.VERSION_MAJOR }}${{ env.VERSION_MINOR }}-${{ inputs.DATE_STAMP }}-${{ env.CLEAN_ARCH }} && \ + sudo podman save \ + ${{ env.IMAGE_NAME }}:${{ inputs.VERSION_MAJOR }}${{ env.VERSION_MINOR }}-${{ inputs.DATE_STAMP }}-${{ env.CLEAN_ARCH }} > \ + /tmp/image-${{ env.IMAGE_NAME }}-${{ inputs.VERSION_MAJOR }}${{ env.VERSION_MINOR }}-${{ inputs.DATE_STAMP }}-${{ env.CLEAN_ARCH }}.tar && \ + sudo gzip /tmp/image-${{ env.IMAGE_NAME }}-${{ inputs.VERSION_MAJOR }}${{ env.VERSION_MINOR }}-${{ inputs.DATE_STAMP }}-${{ env.CLEAN_ARCH }}.tar + - name: Run Image id: run if: ${{ env.res != 0 || github.event_name == 'workflow_dispatch' }} @@ -120,7 +139,7 @@ runs: - name: Push to registry id: push - if: ${{ env.res != 0 || github.event_name == 'workflow_dispatch' }} + if: ${{ (env.res != 0 || github.event_name == 'workflow_dispatch') && github.event_name != 'pull_request' }} env: IMAGE_ID: ${{ steps.rechunk.outputs.image-id }} VERSION: ${{ steps.run.outputs.version-id }} @@ -154,6 +173,15 @@ runs: cat /tmp/outputs/digests/${{ env.IMAGE_NAME }}_${{ matrix.VERSION_MAJOR }}_${{ env.CLEAN_ARCH }}.json + - name: Upload Container Image Artifacts + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + if: ${{ github.event_name == 'pull_request' }} + with: + name: image-${{ env.IMAGE_NAME }}-${{ inputs.VERSION_MAJOR }}${{ env.VERSION_MINOR }}-${{ inputs.DATE_STAMP }}-${{ env.CLEAN_ARCH }}.tar.gz + path: /tmp/image-${{ env.IMAGE_NAME }}-${{ inputs.VERSION_MAJOR }}${{ env.VERSION_MINOR }}-${{ inputs.DATE_STAMP }}-${{ env.CLEAN_ARCH }}.tar.gz + retention-days: 1 + if-no-files-found: error + - name: Upload Output Artifacts if: ${{ env.res != 0 || github.event_name == 'workflow_dispatch' }} uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7c9b990..75b4cd1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,7 @@ name: Build amd64 and arm64 on: + pull_request: + types: [synchronize, opened, reopened] workflow_dispatch: inputs: RELEASE: @@ -36,6 +38,9 @@ jobs: run: | # Format json for versions matrix case ${{ github.event_name }} in + pull_request) + echo "matrix=$(jq -c <<< '[${{ env.VERSIONS_LIST }}]')" >> $GITHUB_OUTPUT + ;; workflow_dispatch) if [[ "${{ inputs.RELEASE }}" == "ALL" ]]; then echo "matrix=$(jq -c <<< '[${{ env.VERSIONS_LIST }}]')" >> $GITHUB_OUTPUT @@ -87,7 +92,7 @@ jobs: REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} push-manifest: - if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} + if: ${{ always() && contains(join(needs.*.result, ','), 'success') && github.event_name != 'pull_request' }} name: Push manifest needs: [set-versions-matrix, build] runs-on: ubuntu-24.04