Skip to content

Commit

Permalink
Merge pull request #65 from IGNF/ghcr
Browse files Browse the repository at this point in the history
WIP Deploy on ghcr.io
  • Loading branch information
leavauchier authored Aug 12, 2024
2 parents ddb60a8 + 642637e commit 3b9af9d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 25 deletions.
76 changes: 52 additions & 24 deletions .github/workflows/cicd_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,80 @@ name: cicd_deploy

on:
push:
# Run deployment on every new tag
tags:
- '*'
# Run deployment on every new version tag and every push to main
branches: [ "main" ]
tags: [ '*.*.*' ]

env:
DOCKER_REPO: ignimagelidar/coclico
IMAGE_NAME: ${{ github.repository }}
REGISTRY: ghcr.io
DOCKER_IMAGE_NAME: coclico
TEST_TAG: coclico:test

jobs:
deploy_docker:
runs-on: ubuntu-latest

steps:
- name: Checkout branch
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and export to Docker
uses: docker/build-push-action@v4
# build the image
- name: Build Docker image for tests
id: build
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: ${{ env.DOCKER_REPO }}:test
tags: ${{ env.TEST_TAG }}

- name: Run tests in docker
run: >
docker run
--ipc=host
${{ env.DOCKER_REPO }}:test
${{ env.TEST_TAG }}
python -m pytest -m docker -s --log-cli-level DEBUG
- name: Set version number
run: |
echo "VERSION=$(python -m coclico.version)" >> $GITHUB_ENV
echo "VERSION=v$(python -m coclico.version)" >> $GITHUB_ENV
- name: Check tag and version number consistency
if: ${{ github.event_name == 'tag' }}
run: |
if [[ ${{ github.ref_name }} == ${{ env.VERSION }} ]]
then
echo "OK: Tag name and VERSION.md (${{ env.VERSION }}) version number (${{ github.ref_name }}) match"
else
echo "NOK: Tag name and VERSION.md (${{ env.VERSION }}) version number (${{ github.ref_name }}) don't match"
exit 1
fi
- name: Build and push
uses: docker/build-push-action@v4
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
if: ${{ github.event_name != 'pull_request' }}
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ env.DOCKER_REPO }}:latest,${{ env.DOCKER_REPO }}:${{ env.VERSION }}

tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.1.1

- L'image docker est maintenant stockée sur ghcr.io

# 1.1.0

- MOBJ0 : Utilisation de la 4-connexité au lieu de 8-connexité pour la génération des formes à partir de la carte
Expand Down
2 changes: 1 addition & 1 deletion coclico/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.1.0"
__version__ = "1.1.1"


if __name__ == "__main__":
Expand Down

0 comments on commit 3b9af9d

Please sign in to comment.