Skip to content
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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ RUN if [ "$BUILD_TYPE" = "release" ]; then \
elif [ "$BUILD_TYPE" = "push" ]; then \
echo "Installing Dojo at commit $DOJO_VERSION"; \
dojoup -c $DOJO_VERSION; \
elif [ "$BUILD_TYPE" = "workflow_dispatch" ]; then \
echo "Installing Dojo at commit $DOJO_VERSION"; \
dojoup -c $DOJO_VERSION; \
Comment on lines +79 to +81
Copy link

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 and workflow_dispatch are performing the same actions. Consider combining them to simplify the script and reduce redundancy.

Apply this diff to refactor the code:

 RUN if [ "$BUILD_TYPE" = "release" ]; then \
     echo "Installing Dojo version $DOJO_VERSION"; \
     dojoup -v $DOJO_VERSION; \
-elif [ "$BUILD_TYPE" = "push" ]; then \
+elif [ "$BUILD_TYPE" = "push" ] || [ "$BUILD_TYPE" = "workflow_dispatch" ]; then \
     echo "Installing Dojo at commit $DOJO_VERSION"; \
     dojoup -c $DOJO_VERSION; \
-elif [ "$BUILD_TYPE" = "workflow_dispatch" ]; then \
-    echo "Installing Dojo at commit $DOJO_VERSION"; \
-    dojoup -c $DOJO_VERSION; \
 else \
     echo "Installing latest stable version of Dojo"; \
     dojoup; \
     fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
elif [ "$BUILD_TYPE" = "workflow_dispatch" ]; then \
echo "Installing Dojo at commit $DOJO_VERSION"; \
dojoup -c $DOJO_VERSION; \
elif [ "$BUILD_TYPE" = "push" ] || [ "$BUILD_TYPE" = "workflow_dispatch" ]; then \
echo "Installing Dojo at commit $DOJO_VERSION"; \
dojoup -c $DOJO_VERSION; \

else \
echo "Installing latest stable version of Dojo"; \
dojoup; \
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:
- 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 "tag_name=$SHORT_SHA" >> $GITHUB_OUTPUT
echo "DOCKER_TAG=${{ inputs.docker_tag }}" >> $GITHUB_ENV

- name: Set outputs
Expand All @@ -64,7 +66,7 @@ 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: |
Expand Down
Loading