diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 8867ce93e..16decf9b5 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -3,42 +3,11 @@ name: Build and Test on: [push, pull_request] env: - IMAGE_TAG: 20240908-1 TESTS_TIMEOUT: 10 # in minutes jobs: build-container: - name: Create build container - runs-on: ubuntu-latest - permissions: - packages: write - - outputs: - image: ${{ steps.check.outputs.image }} - - steps: - - name: Login to GHCR - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ github.token }} - - - name: Check if image already exists on GHCR - id: check - run: | - image=ghcr.io/${{ github.repository_owner }}/xdg-desktop-portal-build:${{ env.IMAGE_TAG }} - echo "exists=$(docker manifest inspect $image >/dev/null && echo 'true' || echo 'false')" \ - >> "$GITHUB_OUTPUT" - echo "image=$image" >> "$GITHUB_OUTPUT" - - - name: Build and push - if: ${{ steps.check.outputs.exists == 'false' }} - uses: docker/build-push-action@v5 - with: - push: true - file: .github/workflows/Containerfile - tags: ghcr.io/${{ github.repository_owner }}/xdg-desktop-portal-build:${{ env.IMAGE_TAG }} + uses: ./.github/workflows/container.yml build-and-test: name: Build and Test diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml new file mode 100644 index 000000000..5c7696c8b --- /dev/null +++ b/.github/workflows/container.yml @@ -0,0 +1,43 @@ +name: Create build container + +env: + IMAGE_TAG: 20240908-1 + +on: + workflow_call: + inputs: + secrets: + +jobs: + build-container: + name: Create build container + runs-on: ubuntu-latest + permissions: + packages: write + + outputs: + image: ${{ steps.check.outputs.image }} + + steps: + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + + - name: Check if image already exists on GHCR + id: check + run: | + image=ghcr.io/${{ github.repository_owner }}/xdg-desktop-portal-build:${{ env.IMAGE_TAG }} + echo "exists=$(docker manifest inspect $image >/dev/null && echo 'true' || echo 'false')" \ + >> "$GITHUB_OUTPUT" + echo "image=$image" >> "$GITHUB_OUTPUT" + + - name: Build and push + if: ${{ steps.check.outputs.exists == 'false' }} + uses: docker/build-push-action@v5 + with: + push: true + file: .github/workflows/Containerfile + tags: ghcr.io/${{ github.repository_owner }}/xdg-desktop-portal-build:${{ env.IMAGE_TAG }} \ No newline at end of file