Fixes image flip #728
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: Boundlexx Build | |
on: | |
push: | |
# Publish `master` as Docker `latest` image. | |
branches: | |
- master | |
# Publish `v1.2.3` tags as releases. | |
tags: | |
- v* | |
# Run tests for any PRs. | |
pull_request: | |
env: | |
DOCKER_BUILDKIT: 1 | |
jobs: | |
# Run tests. | |
# See also https://docs.docker.com/docker-hub/builds/automated-testing/ | |
test: | |
name: Test and Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Fix permissions | |
run: sudo chown -R 1000:1000 $GITHUB_WORKSPACE | |
- name: Log into Registry | |
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u AngellusMortis --password-stdin | |
- name: Pull Cached Images | |
run: | | |
docker pull ghcr.io/angellusmortis/boundlexx_postgres || true | |
docker pull ghcr.io/angellusmortis/boundlexxdjango || true | |
docker pull ghcr.io/angellusmortis/boundlexx_dev_django || true | |
- name: Build CI Images | |
run: docker-compose build postgres test lint | |
- name: Push Django Image Cache | |
run: docker tag boundlexx_dev_django ghcr.io/angellusmortis/boundlexx_dev_django && docker push ghcr.io/angellusmortis/boundlexx_dev_django || true | |
- name: Run Linters | |
run: docker-compose run --rm lint | |
- name: Run Tests | |
run: docker-compose run --rm test | |
# Push image to GitHub Packages. | |
# See also https://docs.docker.com/docker-hub/builds/ | |
push: | |
name: Build Production and Push | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Checkout Client Repository | |
uses: actions/checkout@v2 | |
with: | |
repository: "AngellusMortis/boundlexx_client" | |
token: "${{ secrets.GHCR_PAT }}" | |
path: boundlexx_client | |
- name: Log into Registry | |
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Pull Cached Images | |
run: | | |
docker pull ghcr.io/angellusmortis/boundlexx_postgres || true | |
docker pull ghcr.io/angellusmortis/boundlexx_django || true | |
- name: Build Postgres Image | |
run: docker build -t boundlexx_postgres --cache-from ghcr.io/angellusmortis/boundlexx_postgres -f docker/postgres/Dockerfile . | |
- name: Build Django Image | |
run: docker build -t boundlexx_django --cache-from ghcr.io/angellusmortis/boundlexx_django --target production -f docker/django/Dockerfile . | |
- name: Push Postgres Image | |
run: | | |
IMAGE_ID=ghcr.io/angellusmortis/boundlexx_postgres | |
# 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" == "master" ] && VERSION=latest | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
docker tag boundlexx_postgres $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION | |
- name: Push Django Image | |
run: | | |
IMAGE_ID=ghcr.io/angellusmortis/boundlexx_django | |
# 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" == "master" ] && VERSION=latest | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
docker tag boundlexx_django $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION |