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

Revise Docker CI #1343

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "pypsa earth dev",
"image": "ghcr.io/drifter089/pypsa-earth:latest",
"image": "ghcr.io/pypsa-meets-earth/pypsa-earth:latest",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces,type=bind,consistency=cached",
"initializeCommand": "docker pull ghcr.io/drifter089/pypsa-earth:latest",
"initializeCommand": "docker pull ghcr.io/pypsa-meets-earth/pypsa-earth:latest",
"workspaceFolder": "/workspaces",
"postAttachCommand": "bash .devcontainer/setup.sh"
}
49 changes: 31 additions & 18 deletions .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,39 @@ on:
paths:
- envs/linux-pinned.yaml

env:
IMAGE_NAME: pypsa-earth
#
jobs:
build:
# This pushes the image to GitHub Packages.
push:
runs-on: ubuntu-latest

permissions:
packages: write
contents: read
#
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
#
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME

- name: Build Dev Container Image
uses: devcontainers/[email protected]
with:
subFolder: .github
cacheFrom: ghcr.io/${{ github.repository }}-dev-env
imageName: ghcr.io/${{ github.repository }}-dev-env
push: always
# This changes all uppercase characters to lowercase.
Copy link
Contributor

@drifter089 drifter089 Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we can use the devcontainer action as it will use cache to rebuild the image

IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# This strips the git ref prefix from the version.
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# This strips the "v" prefix from the tag name.
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# This uses the Docker `latest` tag convention.
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
2 changes: 2 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ This part of documentation collects descriptive release notes to capture the mai

* Fix namibia geofk, line country tag mismatch and minor fixes `PR #1330 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/1330>`__

* Minor revision docker workflow to have it working on upstream `PR #1343 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/1343>`__

PyPSA-Earth 0.6.0
=================

Expand Down