-
Notifications
You must be signed in to change notification settings - Fork 1.5k
ci: add historical release image rebuild workflow #2507
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
2 commits
Select commit
Hold shift + click to select a range
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,98 @@ | ||
| name: Rebuild Release Image | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| source_ref: | ||
| description: "Tag or branch to build from" | ||
| required: true | ||
| type: string | ||
| tag: | ||
| description: "Docker image tag to publish" | ||
| required: true | ||
| type: string | ||
|
|
||
| env: | ||
| IMAGE_NAME: nearaidev/ironclaw | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Rebuild Historical Image | ||
| runs-on: ubuntu-24.04 | ||
| permissions: | ||
| actions: write | ||
| contents: read | ||
| packages: read | ||
| steps: | ||
| - name: Checkout requested source | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | ||
| with: | ||
| ref: ${{ inputs.source_ref }} | ||
| persist-credentials: false | ||
|
|
||
| - name: Extract version from Cargo.toml | ||
| id: version | ||
| run: | | ||
| VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/') | ||
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | ||
| echo "Detected version: ${VERSION}" | ||
|
|
||
| - name: Verify requested tag matches source version | ||
| env: | ||
| EXPECTED_TAG: ${{ inputs.tag }} | ||
| SOURCE_REF: ${{ inputs.source_ref }} | ||
| SOURCE_VERSION: ${{ steps.version.outputs.version }} | ||
| run: | | ||
| EXPECTED_REF="ironclaw-v${EXPECTED_TAG}" | ||
| if [[ "${SOURCE_REF}" != "${EXPECTED_REF}" ]]; then | ||
| echo "::error::Expected source_ref '${EXPECTED_REF}' for tag '${EXPECTED_TAG}', got '${SOURCE_REF}'" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "${EXPECTED_TAG}" != "${SOURCE_VERSION}" ]]; then | ||
| echo "::error::Requested tag '${EXPECTED_TAG}' does not match source version '${SOURCE_VERSION}'" | ||
| exit 1 | ||
| fi | ||
|
henrypark133 marked this conversation as resolved.
|
||
|
|
||
| EXPECTED_COMMIT=$(git rev-list -n1 "${EXPECTED_REF}") | ||
| ACTUAL_COMMIT=$(git rev-parse HEAD) | ||
| if [[ "${ACTUAL_COMMIT}" != "${EXPECTED_COMMIT}" ]]; then | ||
| echo "::error::Checked out commit '${ACTUAL_COMMIT}' does not match release tag '${EXPECTED_REF}' (${EXPECTED_COMMIT})" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Compute source SHA | ||
| id: source | ||
| run: | | ||
| echo "sha=$(git rev-parse --short=7 HEAD)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 | ||
|
|
||
| - name: Log in to Docker Hub | ||
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 | ||
| with: | ||
| username: ${{ vars.DOCKER_REGISTRY_USER }} | ||
| password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | ||
|
|
||
| - name: Build and push | ||
| uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6 | ||
| with: | ||
| context: . | ||
| push: true | ||
| tags: ${{ env.IMAGE_NAME }}:${{ inputs.tag }} | ||
| target: runtime | ||
| platforms: linux/amd64 | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
|
||
| - name: Summary | ||
| run: | | ||
| { | ||
| echo "## Rebuilt Docker Image" | ||
| echo "" | ||
| echo "- source ref: \`${{ inputs.source_ref }}\`" | ||
| echo "- source sha: \`${{ steps.source.outputs.sha }}\`" | ||
| echo "- version: \`${{ steps.version.outputs.version }}\`" | ||
| echo "- image: \`${{ env.IMAGE_NAME }}:${{ inputs.tag }}\`" | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
Oops, something went wrong.
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.