laxydl: Don't prematurely delete the tmp download. #604
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: Docker test | |
on: | |
# Allow builds to be triggered from the web UI | |
workflow_dispatch: | |
push: | |
# Publish `master` as Docker `latest` image, `develop` as `dev` image | |
branches: | |
- master | |
- develop | |
# Publish `v1.2.3` tags as releases. | |
tags: | |
- v* | |
# Run tests for any PRs. | |
pull_request: | |
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: Run tests | |
run: | | |
if [ -f docker-compose.test.yml ]; then | |
docker compose --file docker-compose.yml --file docker-compose.test.yml build \ | |
--build-arg GIT_COMMIT=${{ github.sha }} sut | |
docker compose --file docker-compose.yml --file docker-compose.test.yml run sut | |
else | |
docker build . --file docker/laxy/Dockerfile | |
fi | |
# Push image to GitHub Package Registry. | |
# See also https://docs.docker.com/docker-hub/builds/ | |
push: | |
# Ensure test job passes before pushing image. | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set environment variables for all steps | |
run: | | |
export GIT_COMMIT="${{ github.sha }}" | |
echo "GIT_COMMIT=${GIT_COMMIT}" >>$GITHUB_ENV | |
echo "GIT_SHORT_COMMIT=${GIT_COMMIT:0:8}" >>$GITHUB_ENV | |
# Strip git ref prefix from version | |
BRANCH_OR_TAG=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Strip "v" prefix from tag name | |
[ "${{ github.ref }}" == "refs/tags/"* ] && BRANCH_OR_TAG=$(echo $BRANCH_OR_TAG | sed -e 's/^v//') | |
echo "BRANCH_OR_TAG=${BRANCH_OR_TAG}" >>$GITHUB_ENV | |
[ "$BRANCH_OR_TAG" == "master" ] && LAXY_ENV=prod | |
[ "$BRANCH_OR_TAG" == "develop" ] && LAXY_ENV=dev | |
echo "LAXY_ENV=${LAXY_ENV}" >>$GITHUB_ENV | |
IMAGE_TAG=$BRANCH_OR_TAG | |
[ "$BRANCH_OR_TAG" == "master" ] && IMAGE_TAG=latest | |
[ "$BRANCH_OR_TAG" == "develop" ] && IMAGE_TAG=dev | |
echo "IMAGE_TAG=${IMAGE_TAG}" >>$GITHUB_ENV | |
- name: Build Laxy backend image (Django) | |
run: | | |
export LAXY_ENV=${{ env.LAXY_ENV }} | |
docker build . --file docker/laxy/Dockerfile --tag laxy --build-arg GIT_COMMIT=${{ env.GIT_SHORT_COMMIT }} | |
- name: Build Laxy frontend image (nginx + static assets) | |
run: | | |
export LAXY_ENV=${{ env.LAXY_ENV }} | |
# We hard-code these for prod, since for dev/localdev you'll either rebuild with a different .env | |
# or host-bind a working copy of laxy_frontend anyway | |
LAXY_FRONTEND_GOOGLE_OAUTH_CLIENT_ID=474709025289-vm2t2ikg08ij9mvl3h813l86nng1e4eh.apps.googleusercontent.com | |
LAXY_FRONTEND_URL=https://laxy.io | |
LAXY_FRONTEND_API_URL=https://api.laxy.io | |
docker build . --file docker/laxy-static-nginx/Dockerfile --tag laxy-static-nginx \ | |
--build-arg GIT_COMMIT=${{ env.GIT_SHORT_COMMIT }} \ | |
--build-arg LAXY_FRONTEND_GOOGLE_OAUTH_CLIENT_ID=$LAXY_FRONTEND_GOOGLE_OAUTH_CLIENT_ID \ | |
--build-arg LAXY_FRONTEND_URL=$LAXY_FRONTEND_URL \ | |
--build-arg LAXY_FRONTEND_API_URL=$LAXY_FRONTEND_API_URL | |
- name: Log into registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin | |
- name: Push laxy image | |
run: | | |
function to_lower() { | |
echo $1 | tr '[:upper:]' '[:lower:]' | |
} | |
export IMAGE_NAME=laxy | |
export IMAGE_ID=$(to_lower "docker.pkg.github.com/${{ github.repository }}/${IMAGE_NAME}") | |
docker tag "${IMAGE_NAME}" "${IMAGE_ID}:${{ env.IMAGE_TAG }}" | |
docker tag "${IMAGE_NAME}" "${IMAGE_ID}:${{ env.GIT_SHORT_COMMIT }}" | |
echo "Pushing ${IMAGE_ID}:${{ env.IMAGE_TAG }}" | |
docker push "${IMAGE_ID}:${{ env.IMAGE_TAG }}" | |
echo "Pushing ${IMAGE_ID}:${{ env.GIT_SHORT_COMMIT }}" | |
docker push "${IMAGE_ID}:${{ env.GIT_SHORT_COMMIT }}" | |
- name: Push laxy-static-nginx image | |
run: | | |
function to_lower() { | |
echo $1 | tr '[:upper:]' '[:lower:]' | |
} | |
export IMAGE_NAME=laxy-static-nginx | |
export IMAGE_ID=$(to_lower "docker.pkg.github.com/${{ github.repository }}/${IMAGE_NAME}") | |
docker tag "${IMAGE_NAME}" "${IMAGE_ID}:${{ env.IMAGE_TAG }}" | |
docker tag "${IMAGE_NAME}" "${IMAGE_ID}:${{ env.GIT_SHORT_COMMIT }}" | |
echo "Pushing ${IMAGE_ID}:${{ env.IMAGE_TAG }}" | |
docker push "${IMAGE_ID}:${{ env.IMAGE_TAG }}" | |
echo "Pushing ${IMAGE_ID}:${{ env.GIT_SHORT_COMMIT }}" | |
docker push "${IMAGE_ID}:${{ env.GIT_SHORT_COMMIT }}" |