-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
544609a
commit eee5cc3
Showing
1 changed file
with
46 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Publish Docker Image | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
paths: | ||
- docker/** | ||
pull_request: | ||
paths: | ||
- docker/** | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
# TODO: on pull_request for testing. Change to push once verified | ||
jobs: | ||
pull_request: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: read | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set lower case image name | ||
run: echo "IMAGE_LC=${IMAGE_NAME,,}" >>${GITHUB_ENV} | ||
- name: Build image | ||
run: docker build docker --tag $IMAGE_LC --label "runnumber=${GITHUB_RUN_ID}" | ||
- name: Log in to registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login $REGISTRY -u $ --password-stdin | ||
- name: Push image | ||
run: | | ||
IMAGE_ID=ghcr.io/$IMAGE_LC | ||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | ||
# VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
# TODO: testing setting version to python package version. If OK, then remove this line and above | ||
VERSION=$(grep '__version__' src/nebari_plugin_self_registration/__about__.py | awk -F '"' '{print $2}') | ||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | ||
[ "$VERSION" == "main" ] && VERSION=latest | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag $IMAGE_LC $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION |