-
Notifications
You must be signed in to change notification settings - Fork 1.4k
deploy from a fork using a workflow #5668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c07e0be
allow deploying fork PRs before merging
jakecoffman de96bde
use cherry-pick since merging main errors
jakecoffman fd4ee6a
make it clear which PR this was generated for
jakecoffman e60fa8e
Merge branch 'main' into jakecoffman/fork-docker-images
jakecoffman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,88 @@ | ||
| name: Push docker fork images | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| BASE_IMAGE: "ubuntu:20.04" | ||
| UPDATER_IMAGE: "dependabot/updater" | ||
| UPDATER_IMAGE_MIRROR: "ghcr.io/dependabot/dependabot-updater" | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| pr: | ||
| required: true | ||
| type: string | ||
| description: PR number | ||
|
|
||
| jobs: | ||
| push-fork-image: | ||
| name: Build and push fork image | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| env: | ||
| TAG: ${{ github.sha }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Check if pull request is approved | ||
| # The PR must be approved. This is mostly to ensure you've typed the correct PR. | ||
| # Note: forks will have a blank review decision without approval. Not NEEDS_REVIEW. | ||
| run: | | ||
| DECISION=$(gh pr view ${{ github.event.inputs.pr }} --json reviewDecision -t {{.reviewDecision}}) | ||
| echo "Review decision is: $DECISION" | ||
| [[ $DECISION == "APPROVED" ]] || exit 1 | ||
jakecoffman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Checkout the fork | ||
| # This checks out the fork and cherry-picks the changes onto main, creating a new merge SHA tag. | ||
| run: | | ||
| git config --global user.email "you@example.com" | ||
| git config --global user.name "Your Name" | ||
| gh pr checkout ${{ github.event.inputs.pr }} --branch docker-branch-release-workflow | ||
| git reset main | ||
| git add . | ||
| git commit -m squashed | ||
| PICK=$(git rev-parse HEAD) | ||
| git checkout main | ||
| git cherry-pick $PICK | ||
| echo "TAG=$(git rev-parse HEAD)" >> $GITHUB_ENV | ||
|
|
||
| - name: Build dependabot-core image | ||
| env: | ||
| DOCKER_BUILDKIT: 1 | ||
| run: | | ||
| docker build \ | ||
| -t "dependabot/dependabot-core:$TAG" \ | ||
| --build-arg BUILDKIT_INLINE_CACHE=1 \ | ||
| --cache-from ghcr.io/dependabot/dependabot-core \ | ||
| . | ||
|
|
||
| - name: Build dependabot-updater image | ||
| env: | ||
| DOCKER_BUILDKIT: 1 | ||
| run: | | ||
| docker build \ | ||
| -t "$UPDATER_IMAGE:$TAG" \ | ||
| --build-arg BUILDKIT_INLINE_CACHE=1 \ | ||
| --cache-from "$BASE_IMAGE" \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cache from
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I agree, I copied this from another workflow. |
||
| --cache-from "$UPDATER_IMAGE_MIRROR" \ | ||
jakecoffman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| --build-arg OMNIBUS_VERSION=$TAG \ | ||
jakecoffman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| -f Dockerfile.updater \ | ||
| . | ||
|
|
||
| - name: Log in to GHCR | ||
| run: | | ||
| echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
|
||
| - name: Push fork image | ||
| run: | | ||
| docker tag "$UPDATER_IMAGE:$TAG" "$UPDATER_IMAGE_MIRROR:$TAG" | ||
| docker push "$UPDATER_IMAGE_MIRROR:$TAG" | ||
|
|
||
| - name: Set summary | ||
| run: | | ||
| echo "generated for PR ${{ github.event.inputs.pr }}" > $GITHUB_STEP_SUMMARY | ||
| echo "updater uploaded with tag \`$TAG\`" >> $GITHUB_STEP_SUMMARY | ||
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | ||
| echo "$UPDATER_IMAGE_MIRROR:$TAG" >> $GITHUB_STEP_SUMMARY | ||
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.