|
1 | | -name: Create and publish a Docker image |
| 1 | +name: Build and publish a container image |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: ['main'] |
6 | 6 | tags: ['v*'] |
7 | 7 | workflow_dispatch: |
| 8 | + repository_dispatch: |
| 9 | + types: [eodag_release] |
8 | 10 |
|
9 | 11 | env: |
10 | 12 | REGISTRY: ghcr.io |
|
13 | 15 | jobs: |
14 | 16 | build-and-push-image: |
15 | 17 | runs-on: ubuntu-latest |
16 | | - # Sets the permissions granted to the GITHUB_TOKEN for the actions in this job. |
17 | 18 | permissions: |
18 | 19 | contents: read |
19 | 20 | packages: write |
20 | | - attestations: write |
21 | 21 | id-token: write |
22 | 22 |
|
23 | | - # Uses the docker/login-action action to log in to the Container registry |
24 | | - # using the account and password that will publish the packages. Once published, |
25 | | - # the packages are scoped to the account defined here. |
26 | 23 | steps: |
27 | 24 | - name: Checkout repository |
28 | 25 | uses: actions/checkout@v5 |
29 | 26 |
|
| 27 | + - name: Install uv |
| 28 | + uses: astral-sh/setup-uv@v6 |
| 29 | + |
| 30 | + - name: Install dependencies |
| 31 | + run: uv sync --with server --with telemetry |
| 32 | + |
| 33 | + - name: Determine the container tag and labels |
| 34 | + id: container_tag |
| 35 | + run: | |
| 36 | + APP_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml'))['project']['version'])") |
| 37 | + echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV |
| 38 | +
|
| 39 | + EODAG_VERSION=$(PYTHONWARNINGS="ignore::SyntaxWarning" uv run --active python -c "import eodag; print(eodag.__version__)") |
| 40 | + echo "EODAG_VERSION=$EODAG_VERSION" >> $GITHUB_ENV |
| 41 | +
|
| 42 | + # Default: branch name |
| 43 | + CONTAINER_TAG=${GITHUB_REF##*/} |
| 44 | +
|
| 45 | + # Check if this is a release or eodag dispatch |
| 46 | + if [[ "${GITHUB_REF_TYPE}" == "tag" || ( "${GITHUB_EVENT_NAME}" == "repository_dispatch" && "${GITHUB_EVENT_CLIENT_PAYLOAD_TYPE}" == "eodag_release" ) ]]; then |
| 47 | + CONTAINER_TAG="${APP_VERSION}-eodag-${EODAG_VERSION}" |
| 48 | + fi |
| 49 | +
|
| 50 | + echo "CONTAINER_TAG=$CONTAINER_TAG" >> $GITHUB_ENV |
| 51 | +
|
30 | 52 | - name: Set up Docker Buildx |
31 | 53 | uses: docker/setup-buildx-action@v3 |
32 | 54 |
|
33 | | - - name: Log in to the Container registry |
| 55 | + - name: Log in to the container registry |
34 | 56 | uses: docker/login-action@v3 |
35 | 57 | with: |
36 | 58 | registry: ${{ env.REGISTRY }} |
37 | 59 | username: ${{ github.actor }} |
38 | 60 | password: ${{ secrets.GITHUB_TOKEN }} |
39 | 61 |
|
40 | | - # This step uses docker/metadata-action to extract tags and labels that will be applied to the |
41 | | - # specified image. The id "meta" allows the output of this step to be referenced in a subsequent step. |
42 | | - - name: Extract metadata (tags, labels) for Docker |
| 62 | + - name: Extract container metadata |
43 | 63 | id: meta |
44 | 64 | uses: docker/metadata-action@v5 |
45 | 65 | with: |
46 | 66 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 67 | + tags: | |
| 68 | + custom=stac-fastapi-eodag:${{ env.CONTAINER_TAG }} |
| 69 | + labels: | |
| 70 | + org.opencontainers.image.title=stac-fastapi-eodag |
| 71 | + org.opencontainers.image.description=A STAC FastAPI backend using EODAG |
| 72 | + org.opencontainers.image.url=https://github.com/CS-SI/stac-fastapi-eodag |
| 73 | + org.opencontainers.image.source=https://github.com/CS-SI/stac-fastapi-eodag.git |
| 74 | + org.opencontainers.image.licenses=Apache-2.0 |
| 75 | + org.opencontainers.image.authors=CS GROUP - France (CSSI) <eodag@csgroup.space> |
| 76 | + org.opencontainers.image.version=${{ env.APP_VERSION }} |
| 77 | + org.opencontainers.image.eodag.version=${{ env.EODAG_VERSION }} |
47 | 78 |
|
48 | | - # Use the docker/build-push-action action to build the image based on Dockerfile. If the build succeeds, |
49 | | - # it pushes the image to GitHub Packages. It uses the tags and labels parameters to tag and label the image |
50 | | - # with the output from the "meta" step. |
51 | | - - name: Build and push Docker image |
| 79 | + - name: Build and push container image |
52 | 80 | id: push |
53 | 81 | uses: docker/build-push-action@v6 |
54 | 82 | with: |
|
0 commit comments