Enable container builds for multiple registries

next
Sayan Nandan 4 years ago
parent 693d99603e
commit 9d3e5db3a3
No known key found for this signature in database
GPG Key ID: C31EFD7DDA12AEE0

@ -1,18 +1,69 @@
name: Docker Image (GitHub)
name: Docker Image
on:
push:
branches: [ next ]
pull_request:
branches: [ next ]
# Publish `next` as Docker `latest` image.
branches:
- next
jobs:
# Publish `v1.2.3` tags as releases.
tags:
- v*
# Run tests for any PRs.
pull_request:
build:
env:
# TODO: Change variable to your image's name.
IMAGE_NAME: tdb
jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
- uses: actions/checkout@v2
- name: Run tests
run: |
if [ -f docker-compose.test.yml ]; then
docker-compose --file docker-compose.test.yml build
docker-compose --file docker-compose.test.yml run sut
else
docker build . --file Dockerfile
fi
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Push to Docker Hub
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: terrabasedb/tdb
tag_with_ref: true
- name: Log into GitHub Container Registry
run: echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image to GitHub Container Registry
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "next" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION

@ -1,21 +0,0 @@
name: Build docker image
on:
push:
branches:
- next
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build and push Docker images
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: terrabasedb/tdb
tags: latest

@ -11,9 +11,7 @@ RUN \
curl https://sh.rustup.rs -sSf | sh -s -- -y && \
git clone https://github.com/terrabasedb/terrabase.git && \
cd terrabase && \
git fetch --tags && \
lr=`git describe --tags --abbrev=0 --match v*` && \
git checkout $lr && \
git checkout next && \
$HOME/.cargo/bin/cargo build --release -p tdb && \
apt-get remove git curl -y && \
apt-get autoremove -y && \

Loading…
Cancel
Save