1+
2+ name : cicd_deploy
3+
4+ on :
5+ # Also run when the pull request merges (which generates a push)
6+ # So that we can tag the docker image appropriately.
7+ push :
8+ tags : [ 'v*.*.*' ]
9+
10+ env :
11+ IMAGE_NAME : ${{ github.repository }}
12+ REGISTRY : ghcr.io
13+ TEST_TAG : ${{ github.repository }}:test
14+
15+ jobs :
16+ deploy_docker :
17+ runs-on : ubuntu-latest
18+
19+ permissions :
20+ contents : read
21+ packages : write
22+
23+ steps :
24+ - name : Checkout branch
25+ uses : actions/checkout@v4
26+
27+ - name : Build the Docker image
28+ id : build
29+ uses : docker/build-push-action@v6
30+ with :
31+ load : true
32+ tags : ${{ env.TEST_TAG }}
33+
34+ # run the test on the docker image
35+ - name : Run tests in docker image
36+ run : >
37+ docker run
38+ --ipc=host
39+ ${{ env.TEST_TAG }}
40+ python -m pytest -s
41+ --log-cli-level=DEBUG
42+ --log-format="%(asctime)s %(levelname)s %(message)s"
43+ --log-date-format="%Y-%m-%d %H:%M:%S"
44+ -m "not functional_test"
45+
46+ # Login against a Docker registry except on PR
47+ # https://github.com/docker/login-action
48+ - name : Log into registry ${{ env.REGISTRY }}
49+ if : github.event_name != 'pull_request'
50+ uses : docker/login-action@v3.4
51+ with :
52+ registry : ${{ env.REGISTRY }}
53+ username : ${{ github.actor }}
54+ password : ${{ secrets.GITHUB_TOKEN }}
55+
56+ # Extract metadata (tags, labels) for Docker
57+ # https://github.com/docker/metadata-action
58+ - name : Extract Docker metadata
59+ if : github.event_name != 'pull_request'
60+ id : meta
61+ uses : docker/metadata-action@v5
62+ with :
63+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
64+
65+ # Build a Docker image with Buildx (don't on PR)
66+ # https://github.com/docker/build-push-action
67+ - name : Build and push Docker image
68+ if : github.event_name != 'pull_request'
69+ id : build-and-push
70+ uses : docker/build-push-action@v6
71+ with :
72+ context : .
73+ push : true
74+ tags : ${{ steps.meta.outputs.tags }}
75+ labels : ${{ steps.meta.outputs.labels }}
76+
77+ deploy-pypi :
78+ runs-on : ubuntu-latest
79+
80+ environment :
81+ name : pypi
82+ url : https://pypi.org/p/ign-las-digital-models
83+
84+ permissions :
85+ contents : read
86+ packages : write
87+ id-token : write # IMPORTANT: this permission is mandatory for trusted publishing
88+
89+ steps :
90+ - name : Checkout branch
91+ uses : actions/checkout@v4
92+
93+ # See https://github.com/marketplace/actions/setup-micromamba
94+ - name : setup-micromamba
95+ uses : mamba-org/setup-micromamba@v2
96+ with :
97+ environment-file : environment.yml
98+ environment-name : las_digital_models # activate the environment
99+ cache-environment : true
100+ cache-downloads : true
101+ generate-run-shell : true
102+
103+ - name : Run tests with pytest
104+ shell : micromamba-shell {0}
105+ run : python -m pytest ./test -s --log-cli-level DEBUG
106+
107+ - name : Build pip package
108+ shell : micromamba-shell {0}
109+ run : make build
110+
111+ - name : pypi-publish
112+ uses : pypa/gh-action-pypi-publish@v1.12.4
0 commit comments