mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 12:15:47 -04:00
feat: push container images for fork PR
This commit is contained in:
parent
8cdf78f8af
commit
cd120182a9
66
.github/workflows/docker-pr-push.yml
vendored
Normal file
66
.github/workflows/docker-pr-push.yml
vendored
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
name: Docker fork PR push
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: ["Docker"]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
push:
|
||||||
|
# TODO: Push ML as well
|
||||||
|
name: Push fork server image
|
||||||
|
if: ${{ github.event.workflow_run.head_repository.fork }}
|
||||||
|
env:
|
||||||
|
GHCR_REPO: ghcr.io/${{ github.repository_owner }}/immich-server
|
||||||
|
steps:
|
||||||
|
- name: Login to GHCR
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Download image from artifact
|
||||||
|
uses: ishworkh/container-image-artifact-download@v2.0.0
|
||||||
|
with:
|
||||||
|
image: merged-manifest
|
||||||
|
workflow_run_id: ${{ github.event.workflow_run.id }}
|
||||||
|
|
||||||
|
- name: Determine parameters
|
||||||
|
id: parameters
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
let pull_number = context.payload.workflow_run.pull_requests[0]?.number;
|
||||||
|
|
||||||
|
// Adapted from docs-deploy.yml. I'm not sure whether we need this fallback?
|
||||||
|
if(!pull_number) {
|
||||||
|
console.info("Using fallback to get pull request")
|
||||||
|
const response = await github.rest.search.issuesAndPullRequests({q: 'repo:${{ github.repository }} is:pr sha:${{ github.event.workflow_run.head_sha }}',per_page: 1,})
|
||||||
|
const items = response.data.items
|
||||||
|
if (items.length < 1) {
|
||||||
|
throw new Error("No pull request found for the commit")
|
||||||
|
}
|
||||||
|
pull_number = items[0].number
|
||||||
|
}
|
||||||
|
|
||||||
|
parameters = {
|
||||||
|
pr_number: pull_number,
|
||||||
|
head_sha: context.payload.workflow_run.head_sha
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(parameters);
|
||||||
|
return parameters;
|
||||||
|
|
||||||
|
- name: Push
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create \
|
||||||
|
-t ${{ env.GHCR_REPO }}:commit-${{ steps.parameters.outputs.head_sha }} \
|
||||||
|
-t ${{ env.GHCR_REPO }}:pr-${{ steps.parameters.outputs.pr_number }} \
|
||||||
|
merged-manifest
|
6
.github/workflows/docker.yml
vendored
6
.github/workflows/docker.yml
vendored
@ -428,6 +428,12 @@ jobs:
|
|||||||
if: ${{ !github.event.pull_request.head.repo.fork }}
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||||
run: docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") merged-manifest
|
run: docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") merged-manifest
|
||||||
|
|
||||||
|
- name: Save artifact
|
||||||
|
if: ${{ github.event.pull_request.head.repo.fork }}
|
||||||
|
uses: ishworkh/container-image-artifact-upload@v2.0.0
|
||||||
|
with:
|
||||||
|
image: merged-manifest
|
||||||
|
|
||||||
success-check-server:
|
success-check-server:
|
||||||
name: Docker Build & Push Server Success
|
name: Docker Build & Push Server Success
|
||||||
needs: [merge_server, retag_server]
|
needs: [merge_server, retag_server]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user