Debian Codegraph @

.github/workflows/push_docker_tag.yml

raw
1 name: Push specific Docker tag
2
3 on:
4 workflow_dispatch:
5 inputs:
6 version_tag:
7 description: Datasette release tag to build (e.g. 0.65.4); Dockerfile comes from the selected branch
8 required: true
9 type: string
10 push_latest:
11 description: Also update the latest Docker tag
12 type: boolean
13 default: false
14
15 permissions:
16 contents: read
17
18 jobs:
19 deploy_docker:
20 runs-on: ubuntu-latest
21 env:
22 REPO: datasetteproject/datasette
23 VERSION_TAG: ${{ inputs.version_tag }}
24 steps:
25 - uses: actions/checkout@v7
26 - name: Validate version tag
27 run: |-
28 if [[ ! "$VERSION_TAG" =~ ^[0-9][A-Za-z0-9_.-]{0,127}$ ]]; then
29 echo "Expected a release tag such as 0.65.4"
30 exit 1
31 fi
32 git ls-remote --exit-code --tags origin "refs/tags/$VERSION_TAG"
33 - name: Build image
34 run: |-
35 docker build --pull -f Dockerfile \
36 -t "$REPO:$VERSION_TAG" \
37 --build-arg "VERSION=$VERSION_TAG" .
38 - name: Check image before publishing
39 run: |-
40 docker run --rm "$REPO:$VERSION_TAG" datasette --version
41 docker run --rm "$REPO:$VERSION_TAG" pip check
42 docker run --rm "$REPO:$VERSION_TAG" python -c 'import sqlite3; conn = sqlite3.connect(":memory:"); conn.enable_load_extension(True); conn.load_extension("/usr/lib/x86_64-linux-gnu/mod_spatialite.so"); print(conn.execute("select spatialite_version()").fetchone()[0])'
43 - name: Log in to Docker Hub
44 env:
45 DOCKER_USER: ${{ secrets.DOCKER_USER }}
46 DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
47 run: |-
48 printf '%s' "$DOCKER_PASS" | docker login --username "$DOCKER_USER" --password-stdin
49 - name: Push release tag
50 run: docker push "$REPO:$VERSION_TAG"
51 - name: Push latest tag
52 if: ${{ inputs.push_latest }}
53 run: |-
54 docker tag "$REPO:$VERSION_TAG" "$REPO:latest"
55 docker push "$REPO:latest"