-
Notifications
You must be signed in to change notification settings - Fork 189
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
ci: push devcontainer on workflow dispatch #2485
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,17 +43,21 @@ jobs: | |
if: github.event_name == 'release' | ||
run: | | ||
echo "DOCKER_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | ||
echo "DOJO_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | ||
echo "tag_name=$DOCKER_TAG" >> $GITHUB_OUTPUT | ||
|
||
- name: Set Docker tag for push event | ||
if: github.event_name == 'push' | ||
run: | | ||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c 1-7) | ||
echo "DOCKER_TAG=$SHORT_SHA" >> $GITHUB_ENV | ||
echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_ENV | ||
|
||
- name: Set Docker tag for workflow_dispatch event | ||
if: github.event_name == 'workflow_dispatch' | ||
run: | | ||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c 1-7) | ||
echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_ENV | ||
Comment on lines
+59
to
+60
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. Ohayo, sensei! Let's clarify the version setting for workflow_dispatch. The addition of
Consider the following changes: - SHORT_SHA=$(echo "${{ github.sha }}" | cut -c 1-7)
- echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_ENV
+ SHORT_SHA=$(echo "${{ github.sha }}" | cut -c 1-7)
+ echo "DOJO_VERSION=\"${{ inputs.docker_tag }}\"" >> $GITHUB_ENV This aligns
|
||
echo "DOCKER_TAG=${{ inputs.docker_tag }}" >> $GITHUB_ENV | ||
|
||
- name: Set outputs | ||
|
@@ -64,13 +68,13 @@ jobs: | |
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/')) }} | ||
push: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/')) || github.event_name == 'workflow_dispatch' }} | ||
file: .devcontainer/Dockerfile | ||
tags: ghcr.io/${{ github.repository }}-dev:latest,ghcr.io/${{ github.repository }}-dev:${{ env.DOCKER_TAG }} | ||
build-args: | | ||
VARIANT=bookworm | ||
BUILD_TYPE=${{ github.event_name }} | ||
DOJO_VERSION=${{ github.event.release.tag_name }} | ||
DOJO_VERSION=${{ env.DOJO_VERSION }} | ||
platforms: linux/amd64,linux/arm64 | ||
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}-dev:latest | ||
|
||
|
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.
🛠️ Refactor suggestion
Ohayo, sensei! Avoid code duplication by consolidating conditions
The blocks for
push
andworkflow_dispatch
are performing the same actions. Consider combining them to simplify the script and reduce redundancy.Apply this diff to refactor the code:
📝 Committable suggestion