Bump docker/metadata-action from 4 to 5 (#32) #139
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create container image | |
on: | |
merge_group: | |
pull_request: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
env: | |
TEST_TAG: ghcr.io/dekkers/xtdb-http-multinode:test | |
jobs: | |
create_container_image: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/${{ github.repository }} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=tag | |
type=ref,event=pr | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
id: buildx | |
- name: Build and export to local docker | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
load: true | |
tags: ${{ env.TEST_TAG }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
id: py311 | |
with: | |
python-version: 3.11 | |
cache: pip | |
- name: Install test dependencies | |
run: pip install -r tests/requirements.txt | |
- name: Run tests | |
run: | | |
docker run --rm --name xtdb-test -d -p 127.0.0.1:3000:3000 ${{ env.TEST_TAG }} | |
sleep 5 | |
pytest | |
docker kill xtdb-test | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push container image | |
uses: docker/build-push-action@v6 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
# We don't use git context because that doesn't process .dockerignore | |
# https://github.com/docker/cli/issues/2827 | |
context: . | |
push: |- | |
${{ | |
github.event_name == 'push' || | |
( | |
github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login && | |
github.actor != 'dependabot[bot]' | |
) | |
}} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
platforms: linux/arm64,linux/amd64 |