Skip to content

move execute migrations script #102

move execute migrations script

move execute migrations script #102

Workflow file for this run

name: Master Branch Workflow
on:
push:
branches: [ master ]
#set environment variables
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
APP_NAME: async-url-shortener
IMAGE_NAME: shortener
jobs:
pytest_with_coverage:
# Run pytest, upload coverage to a githubs gist so that badge can display it
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: pass
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.12
uses: actions/setup-python@v2
with:
python-version: '3.12'
- name: Install dependencies
run: requirements.txt
- name: Test with pytest
run: |
pytest --cov=shortener
env:
DB_HOST: localhost
DB_PORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port
DB_DATABASE: postgres
DB_USER: postgres
DB_PASSWORD: pass
GITHUB_TOKEN: ${{ secrets.GH_GIST_KEY }}
publishdocker:
# Publish Docker image to GitHubs docker repository
needs: pytest_with_coverage
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v2
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
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" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION