-
Notifications
You must be signed in to change notification settings - Fork 6
Update action to use prebuilt Docker image #140
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
Open
mrfelton
wants to merge
7
commits into
launchdarkly:main
Choose a base branch
from
LN-Zap:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5945752
Prebuild docker image
mrfelton 865c877
Add .version manifest
mrfelton a833b39
Update version check reference
mrfelton 1cbc60e
Build to local registry for testing
mrfelton 9bfc80e
Force usage of locally build docker image
mrfelton 4f8d672
Modify action to use local registry before running
mrfelton 25ce55a
Merge pull request #1 from LN-Zap/container-prebuilt
mrfelton 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,115 @@ | ||
| # When a PR is merged, or when run manually, this workflow will create a | ||
| # release and publish the container image to the GitHub Container Registry. Both | ||
| # will be labeled with the version specified in the manifest file. | ||
| name: Continuous Delivery | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: | ||
| - closed | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| CONTAINER_REGISTRY: ghcr.io | ||
| CONTAINER_REGISTRY_USERNAME: ${{ github.actor }} | ||
| CONTAINER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | ||
| MANIFEST_PATH: .version | ||
|
|
||
| permissions: | ||
| contents: write | ||
| packages: write | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Publish Container Image | ||
| runs-on: ubuntu-latest | ||
|
|
||
| # Ignore Dependabot pull requests. | ||
| if: | | ||
| github.event_name == 'workflow_dispatch' || | ||
| (github.event.pull_request.merged == true && | ||
| startsWith(github.head_ref, 'dependabot/') == false) | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| id: checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-tags: true | ||
| ref: main | ||
|
|
||
| - name: Check Version | ||
| id: version | ||
| uses: issue-ops/semver@v2 | ||
| with: | ||
| check-only: true | ||
| manifest-path: ${{ env.MANIFEST_PATH }} | ||
| ref: main | ||
| workspace: ${{ github.workspace }} | ||
|
|
||
| # Create the list of image tags that will be published. If a prerelease is | ||
| # being published (e.g. `1.2.3-alpha.4`), only the prerelease tag will be | ||
| # published (`v1.2.3-alpha.4`). Otherwise, the following tags will be | ||
| # published: | ||
| # - `latest` | ||
| # - `v1.2.3` | ||
| # - `v1.2` | ||
| # - `v1` | ||
| - name: Set Image Tags | ||
| id: tags | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const version = '${{ steps.version.outputs.version }}' | ||
|
|
||
| // Check if prerelease (e.g. 1.2.3-alpha.4) | ||
| if (version.includes('-')) { | ||
| // Only output the prerelease tag | ||
| core.setOutput('tags', `type=raw,value=v${version}`) | ||
| } else { | ||
| // Output all the tags | ||
| let tags = [ | ||
| 'type=raw,value=latest', | ||
| `type=raw,value=v${version}`, | ||
| `type=raw,value=v${version.split('.').slice(0, 2).join('.')}`, | ||
| `type=raw,value=v${version.split('.')[0]}` | ||
| ] | ||
| core.setOutput('tags', tags.join('\n')) | ||
| } | ||
|
|
||
| # Get metadata to apply to image | ||
| - name: Extract Metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.CONTAINER_REGISTRY }}/${{ github.repository }} | ||
| tags: ${{ steps.tags.outputs.tags }} | ||
|
|
||
| # Authenticate to the container registry | ||
| - name: Authenticate to Container Registry | ||
| id: login | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.CONTAINER_REGISTRY }} | ||
| username: ${{ env.CONTAINER_REGISTRY_USERNAME }} | ||
| password: ${{ env.CONTAINER_REGISTRY_PASSWORD }} | ||
|
|
||
| # Publish the container image | ||
| - name: Publish Container Image | ||
| id: publish | ||
| uses: docker/build-push-action@v6 | ||
| env: | ||
| LABELS: ${{ steps.meta.outputs.labels }} | ||
| TAGS: ${{ steps.meta.outputs.tags }} | ||
| with: | ||
| labels: ${{ env.LABELS }} | ||
| push: true | ||
| tags: ${{ env.TAGS }} | ||
|
|
||
| - name: Create Release | ||
| id: release | ||
| uses: issue-ops/releaser@v2 | ||
| with: | ||
| tag: v${{ steps.version.outputs.version }} |
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
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,39 @@ | ||
| # This workflow checks the version of the container image that is being built | ||
| # in the current pull request. If the version has already been published, the | ||
| # workflow fails to prevent PRs from being merged until the version has been | ||
| # incremented in the manifest file. | ||
| name: Version Check | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| env: | ||
| MANIFEST_PATH: .version | ||
|
|
||
| permissions: | ||
| checks: write | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| check-version: | ||
| name: Version Check | ||
| runs-on: ubuntu-latest | ||
|
|
||
| if: ${{ github.actor != 'dependabot[bot]' }} | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| id: checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-tags: true | ||
|
|
||
| - name: Check Version | ||
| id: check-version | ||
| uses: issue-ops/semver@v2 | ||
| with: | ||
| check-only: true | ||
| manifest-path: ${{ env.MANIFEST_PATH }} |
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 @@ | ||
| v1.0.0 |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we want to push to the
ln-zapnamespace. Can we use thelaunchdarklyorganization here instead?