-
-
Notifications
You must be signed in to change notification settings - Fork 553
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
Build & Push Docker Images on releases #3661
Draft
arjxn-py
wants to merge
6
commits into
pybamm-team:develop
Choose a base branch
from
arjxn-py:docker-images-on-release
base: develop
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.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6f9ce65
Build & Push Docker Images on release
arjxn-py 3cd6573
#3312 initial setup, configure release tags via name
agriyakhetarpal 83fda19
Temporary changes to test tag generation
arjxn-py a269e9b
Skip login step temporarily
arjxn-py 5b8b83d
Try using `github.ref_name` instead
arjxn-py bc0fa0b
Revert temporary changes
arjxn-py 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 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 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,61 +1,88 @@ | ||||||||||
name: Build and push Docker images to Docker Hub | ||||||||||
|
||||||||||
on: | ||||||||||
workflow_dispatch: | ||||||||||
push: | ||||||||||
branches: | ||||||||||
- develop | ||||||||||
|
||||||||||
jobs: | ||||||||||
build_docker_images: | ||||||||||
# This workflow is only of value to PyBaMM and would always be skipped in forks | ||||||||||
if: github.repository_owner == 'pybamm-team' | ||||||||||
name: Image (${{ matrix.build-args }}) | ||||||||||
runs-on: ubuntu-latest | ||||||||||
strategy: | ||||||||||
matrix: | ||||||||||
build-args: ["No solvers", "JAX", "ODES", "IDAKLU", "ALL"] | ||||||||||
fail-fast: true | ||||||||||
|
||||||||||
steps: | ||||||||||
- name: Checkout | ||||||||||
uses: actions/checkout@v4 | ||||||||||
|
||||||||||
- name: Set up QEMU | ||||||||||
uses: docker/setup-qemu-action@v3 | ||||||||||
|
||||||||||
- name: Set up Docker Buildx | ||||||||||
uses: docker/setup-buildx-action@v3 | ||||||||||
|
||||||||||
- name: Login to Docker Hub | ||||||||||
uses: docker/login-action@v3 | ||||||||||
with: | ||||||||||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||||||||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||||||||
|
||||||||||
- name: Create tags for Docker images based on build-time arguments | ||||||||||
id: tags | ||||||||||
run: | | ||||||||||
if [ "${{ matrix.build-args }}" = "No solvers" ]; then | ||||||||||
echo "tag=latest" >> "$GITHUB_OUTPUT" | ||||||||||
elif [ "${{ matrix.build-args }}" = "JAX" ]; then | ||||||||||
echo "tag=jax" >> "$GITHUB_OUTPUT" | ||||||||||
elif [ "${{ matrix.build-args }}" = "ODES" ]; then | ||||||||||
echo "tag=odes" >> "$GITHUB_OUTPUT" | ||||||||||
elif [ "${{ matrix.build-args }}" = "IDAKLU" ]; then | ||||||||||
echo "tag=idaklu" >> "$GITHUB_OUTPUT" | ||||||||||
elif [ "${{ matrix.build-args }}" = "ALL" ]; then | ||||||||||
echo "tag=all" >> "$GITHUB_OUTPUT" | ||||||||||
fi | ||||||||||
|
||||||||||
- name: Build and push Docker image to Docker Hub (${{ matrix.build-args }}) | ||||||||||
uses: docker/build-push-action@v5 | ||||||||||
with: | ||||||||||
context: . | ||||||||||
file: scripts/Dockerfile | ||||||||||
tags: pybamm/pybamm:${{ steps.tags.outputs.tag }} | ||||||||||
push: true | ||||||||||
platforms: linux/amd64, linux/arm64 | ||||||||||
|
||||||||||
- name: List built image(s) | ||||||||||
run: docker images | ||||||||||
name: Build and push Docker images to Docker Hub | ||||||||||
|
||||||||||
on: | ||||||||||
workflow_dispatch: | ||||||||||
push: | ||||||||||
branches: | ||||||||||
- develop | ||||||||||
release: | ||||||||||
types: [published] | ||||||||||
|
||||||||||
Comment on lines
+8
to
+9
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.
Suggested change
in light of #3661 (comment). The changes from this PR won't be available until |
||||||||||
jobs: | ||||||||||
build_docker_images: | ||||||||||
# This workflow is only of value to PyBaMM and would always be skipped in forks | ||||||||||
if: github.repository_owner == 'pybamm-team' | ||||||||||
name: Image (${{ matrix.build-args }}) | ||||||||||
runs-on: ubuntu-latest | ||||||||||
strategy: | ||||||||||
matrix: | ||||||||||
build-args: ["No solvers", "JAX", "ODES", "IDAKLU", "ALL"] | ||||||||||
fail-fast: true | ||||||||||
|
||||||||||
steps: | ||||||||||
- name: Checkout | ||||||||||
uses: actions/checkout@v4 | ||||||||||
|
||||||||||
- name: Set up QEMU | ||||||||||
uses: docker/setup-qemu-action@v3 | ||||||||||
|
||||||||||
- name: Set up Docker Buildx | ||||||||||
uses: docker/setup-buildx-action@v3 | ||||||||||
|
||||||||||
- name: Login to Docker Hub | ||||||||||
uses: docker/login-action@v3 | ||||||||||
with: | ||||||||||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||||||||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||||||||
|
||||||||||
- name: Create tags for Docker images based on build-time arguments | ||||||||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' && github.event_name != 'release' | ||||||||||
id: tags | ||||||||||
run: | | ||||||||||
if [ "${{ matrix.build-args }}" = "No solvers" ]; then | ||||||||||
echo "tag=latest" >> "$GITHUB_OUTPUT" | ||||||||||
elif [ "${{ matrix.build-args }}" = "JAX" ]; then | ||||||||||
echo "tag=jax" >> "$GITHUB_OUTPUT" | ||||||||||
elif [ "${{ matrix.build-args }}" = "ODES" ]; then | ||||||||||
echo "tag=odes" >> "$GITHUB_OUTPUT" | ||||||||||
elif [ "${{ matrix.build-args }}" = "IDAKLU" ]; then | ||||||||||
echo "tag=idaklu" >> "$GITHUB_OUTPUT" | ||||||||||
elif [ "${{ matrix.build-args }}" = "ALL" ]; then | ||||||||||
echo "tag=all" >> "$GITHUB_OUTPUT" | ||||||||||
fi | ||||||||||
|
||||||||||
- name: Create tags for Docker images based on build-time arguments (release) | ||||||||||
if: github.event_name == 'release' && github.event.action == 'published' | ||||||||||
id: tags-release | ||||||||||
run: | | ||||||||||
if [ "${{ matrix.build-args }}" = "No solvers" ]; then | ||||||||||
echo "tag=${{ github.ref_name }}-latest" >> "$GITHUB_OUTPUT" | ||||||||||
elif [ "${{ matrix.build-args }}" = "JAX" ]; then | ||||||||||
echo "tag=${{ github.ref_name }}-jax" >> "$GITHUB_OUTPUT" | ||||||||||
elif [ "${{ matrix.build-args }}" = "ODES" ]; then | ||||||||||
echo "tag=${{ github.ref_name }}-odes" >> "$GITHUB_OUTPUT" | ||||||||||
elif [ "${{ matrix.build-args }}" = "IDAKLU" ]; then | ||||||||||
echo "tag=${{ github.ref_name }}-idaklu" >> "$GITHUB_OUTPUT" | ||||||||||
elif [ "${{ matrix.build-args }}" = "ALL" ]; then | ||||||||||
echo "tag=${{ github.ref_name }}-all" >> "$GITHUB_OUTPUT" | ||||||||||
fi | ||||||||||
|
||||||||||
- name: Build and push Docker image to Docker Hub (${{ matrix.build-args }}) | ||||||||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' && github.event_name != 'release' | ||||||||||
uses: docker/build-push-action@v5 | ||||||||||
with: | ||||||||||
context: . | ||||||||||
file: scripts/Dockerfile | ||||||||||
tags: pybamm/pybamm:${{ steps.tags.outputs.tag }} | ||||||||||
push: true | ||||||||||
platforms: linux/amd64, linux/arm64 | ||||||||||
|
||||||||||
- name: Build and push Docker image to Docker Hub (${{ matrix.build-args}}) (Release) | ||||||||||
if: github.event_name == 'release' && github.event.action == 'published' | ||||||||||
uses: docker/build-push-action@v5 | ||||||||||
with: | ||||||||||
context: . | ||||||||||
file: scripts/Dockerfile | ||||||||||
tags: pybamm/pybamm:${{ steps.tags-release.outputs.tag }} | ||||||||||
push: true | ||||||||||
platforms: linux/amd64, linux/arm64 |
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.
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.
The entire file shows up as changed, possibly due to a difference in line endings schemes?