Skip to content

Commit

Permalink
ci: test ghcr container
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjermiah committed Jan 22, 2024
1 parent 7679997 commit d2b186a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
51 changes: 26 additions & 25 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
run: poetry run make html --directory docs/

Continuous-Deployment:
permissions:
contents: read
packages: write
# needs: Continuous-Integration

# if pulling to main, deploy to PyPI
Expand All @@ -72,13 +75,6 @@ jobs:
- name: Install package
run: poetry install


# Get the last tag value (i.e 0.6.0)
# save to a variable called last_tag to be used later
- name: Get latest tag name
id: last_tag
run: echo ::set-output name=tag::$(git describe --tags --abbrev=0 | sed 's/^v//')

# This action uses Python Semantic Release v8
# What this action does:
# - Determines the next version number based on the commit history
Expand Down Expand Up @@ -119,25 +115,11 @@ jobs:
run: |
printf "%s\n" "${LATEST_TAG}"
- name: Get branch name
run: |
echo "BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_ENV"
- name: Print branch name
run: |
printf "%s\n" "${BRANCH_NAME}"
- name: Set docker image tag
run: |
if [ -z "${LATEST_TAG}" ]; then
echo "DOCKER_IMAGE_TAG=${BRANCH_NAME}" >> "$GITHUB_ENV"
else
echo "DOCKER_IMAGE_TAG=${LATEST_TAG}" >> "$GITHUB_ENV"
fi
- name: Print docker image tag
run: |
printf "%s\n" "${DOCKER_IMAGE_TAG}"
printf "LATEST TAG: %s\n" "${LATEST_TAG}"
echo "DOCKER_IMAGE_TAG=${LATEST_TAG}" >> "$GITHUB_ENV"
printf "DOCKER_IMAGE_TAG: %s\n" "${DOCKER_IMAGE_TAG}"
- name: Set up QEMU
if: steps.release.outputs.released == 'true'
Expand All @@ -154,6 +136,22 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to the GitHub Container Registry
if: steps.release.outputs.released == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
ghcr.io/${{ github.repository }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
- name: Build
if: steps.release.outputs.released == 'true'
uses: docker/build-push-action@v5
Expand All @@ -162,7 +160,10 @@ jobs:
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
ghcr.io/${{ github.repository }}/nbiatoolkit:${{ env.DOCKER_IMAGE_TAG }}
labels: ${{ steps.meta.outputs.labels }}

- name: Test Image
if: steps.release.outputs.released == 'true'
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
# repository:
# docker build -t nbiatoolkit .
#

# ADD LABELS HERE
FROM python:3.12-slim

LABEL maintainer="Jermiah Joseph"
LABEL org.opencontainers.image.source=https://github.com/jjjermiah/nbiatoolkit

# install the dependencies
RUN python -m pip install nbiatoolkit

Expand Down

0 comments on commit d2b186a

Please sign in to comment.