-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: push container images for fork PR
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/[email protected] | ||
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 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -428,6 +428,12 @@ jobs: | |
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 | ||
|
||
- name: Save artifact | ||
if: ${{ github.event.pull_request.head.repo.fork }} | ||
uses: ishworkh/[email protected] | ||
with: | ||
image: merged-manifest | ||
|
||
success-check-server: | ||
name: Docker Build & Push Server Success | ||
needs: [merge_server, retag_server] | ||
|