|
| 1 | +name: Publish Pygeoapi Docker Image |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - "pygeoapi/**" |
| 8 | + - "data/**" |
| 9 | + - ".github/workflows/pygeoapi-image.yml" |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + packages: write |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-and-push: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Set up Docker Buildx |
| 23 | + uses: docker/setup-buildx-action@v3 |
| 24 | + |
| 25 | + - name: Bump repo version |
| 26 | + run: | |
| 27 | + VERSION=$(cat VERSION) |
| 28 | + IFS='.' read -r MAJ MIN PATCH <<<"$VERSION" |
| 29 | + PATCH=$((PATCH+1)) |
| 30 | + NEW_VERSION="$MAJ.$MIN.$PATCH" |
| 31 | + echo "$NEW_VERSION" > VERSION |
| 32 | + echo "VERSION=$NEW_VERSION" >> "$GITHUB_ENV" |
| 33 | +
|
| 34 | + - name: Commit version bump |
| 35 | + run: | |
| 36 | + git config user.name "GitHub Actions" |
| 37 | + git config user.email "actions@github.com" |
| 38 | + git add VERSION |
| 39 | + git commit -m "chore: bump repo version to $VERSION" && git push || echo "No changes to commit" |
| 40 | +
|
| 41 | + - name: Get pygeoapi version |
| 42 | + id: pgv |
| 43 | + run: | |
| 44 | + PYGEOAPI_VERSION=$(docker run --rm geopython/pygeoapi:latest pygeoapi --version | awk '{print $2}') |
| 45 | + echo "PYGEOAPI_VERSION=$PYGEOAPI_VERSION" >> "$GITHUB_OUTPUT" |
| 46 | +
|
| 47 | + - name: Log in to GHCR |
| 48 | + uses: docker/login-action@v3 |
| 49 | + with: |
| 50 | + registry: ghcr.io |
| 51 | + username: ${{ github.actor }} |
| 52 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + |
| 54 | + - name: Build and push Docker image |
| 55 | + uses: docker/build-push-action@v6 |
| 56 | + with: |
| 57 | + context: . |
| 58 | + file: ./docker/Dockerfile.pygeoapi |
| 59 | + push: true |
| 60 | + build-args: | |
| 61 | + REPO_VERSION=${{ env.VERSION }} |
| 62 | + tags: | |
| 63 | + ghcr.io/${{ github.repository_owner }}/pygeoapi-w-global-tsunami-data:latest |
| 64 | + ghcr.io/${{ github.repository_owner }}/pygeoapi-w-global-tsunami-data:${{ steps.pgv.outputs.PYGEOAPI_VERSION }}-${{ env.VERSION }} |
0 commit comments