diff --git a/.github/workflows/pr-build-container-image.yml b/.github/workflows/build-container-image.yml similarity index 84% rename from .github/workflows/pr-build-container-image.yml rename to .github/workflows/build-container-image.yml index f9ec8a1d81..431d4d0a6a 100644 --- a/.github/workflows/pr-build-container-image.yml +++ b/.github/workflows/build-container-image.yml @@ -1,4 +1,4 @@ -name: PRs » Build container image +name: Build » Container image on: push: @@ -22,7 +22,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build and push images + - name: Build image uses: docker/build-push-action@v6 with: push: false # This is handled in another workflow! @@ -30,8 +30,8 @@ jobs: labels: ${{ steps.meta.outputs.labels }} outputs: type=docker,dest=${{ runner.temp }}/build.tar - - name: Upload docker image to GHA + - name: Upload docker image to GHA artifacts uses: actions/upload-artifact@v4 with: - name: build + name: ${{ github.run_id }} path: ${{ runner.temp }}/build.tar diff --git a/.github/workflows/pr-build-test-branch.yml b/.github/workflows/pr-build-test-branch.yml index 9934e29777..2c0cd2fe8a 100644 --- a/.github/workflows/pr-build-test-branch.yml +++ b/.github/workflows/pr-build-test-branch.yml @@ -66,7 +66,7 @@ jobs: - name: Upload build to GHA uses: actions/upload-artifact@v4 with: - name: build + name: ${{ github.run_id }} path: ${{ runner.temp }}/build.tar diff --git a/.github/workflows/pr-deploy-container-image.yml b/.github/workflows/pr-deploy-container-image.yml index d8cdb016fb..1b2c3af5da 100644 --- a/.github/workflows/pr-deploy-container-image.yml +++ b/.github/workflows/pr-deploy-container-image.yml @@ -2,7 +2,7 @@ name: PRs » Push container image on: workflow_run: - workflows: ["PRs » Build container image"] + workflows: ["Build » Container image"] types: - completed @@ -13,6 +13,7 @@ jobs: contents: read packages: write pull-requests: write + if: github.event.workflow_run.event == 'pull_request' steps: - name: Log in to the container registry uses: docker/login-action@v3 @@ -21,28 +22,26 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository }} - - name: Download docker image from GHA uses: actions/download-artifact@v4 with: - name: build + name: ${{ github.event.workflow_run.id }} path: ${{ runner.temp }} + github-token: ${{ github.token }} run-id: ${{ github.event.workflow_run.id }} - name: Load image run: | docker load --input ${{ runner.temp }}/build.tar - docker push ghcr.io/${{ github.repository }} + + - name: Push main branch image + run: | + docker push ghcr.io/${{ github.repository_owner }}/admin-interface:pr-${{ github.event.workflow_run.pull_requests[0].number }} - name: Add comment - if: github.event_name == 'pull_request' uses: thollander/actions-comment-pull-request@v3 with: + pr-number: ${{ github.event.workflow_run.pull_requests[0].number }} comment-tag: container-image message: | Use `docker` or `podman` to test this pull request locally. diff --git a/.github/workflows/pr-deploy-test-branch.yml b/.github/workflows/pr-deploy-test-branch.yml index 6da7d97bde..98a2ac3979 100644 --- a/.github/workflows/pr-deploy-test-branch.yml +++ b/.github/workflows/pr-deploy-test-branch.yml @@ -42,8 +42,9 @@ jobs: - name: Fetch build from GHA uses: actions/download-artifact@v4 with: - name: build - path: ${{ runner.temp }}/build.tar + name: ${{ github.event.workflow_run.id }} + path: ${{ runner.temp }}/ + github-token: ${{ github.token }} run-id: ${{ github.event.workflow_run.id }} - name: Store build in the clone @@ -73,7 +74,7 @@ jobs: working-directory: admin-interface-test run: | git add . - git commit --amend -m "Build ${{ steps.build-path.outputs.build }}" + git commit --amend -m "Build ${{ github.event.workflow_run.pull_requests[0].number }}" - name: Force push admin interface test branch working-directory: admin-interface-test @@ -83,6 +84,7 @@ jobs: - name: Add comment with deployment location uses: thollander/actions-comment-pull-request@v3 with: + pr-number: ${{ github.event.workflow_run.pull_requests[0].number }} comment-tag: static-test-deployment message: > This pull request is deployed at diff --git a/.github/workflows/pr-remove-test-branch.yml b/.github/workflows/pr-remove-test-branch.yml index 98ea7d6566..cbc647482c 100644 --- a/.github/workflows/pr-remove-test-branch.yml +++ b/.github/workflows/pr-remove-test-branch.yml @@ -32,7 +32,7 @@ jobs: - name: Clone test repository run: | - git clone -b gh-pages "git@github.com:opencast/admin-interface-test.git" admin-interface-test + git clone -b gh-pages "git@github.com:${{ github.repository_owner }}/admin-interface-test.git" admin-interface-test - name: Delete build if present working-directory: admin-interface-test