reformat of readme #2
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: BUILD & PUSH ON GHCR | |
on: | |
push: | |
branches: main | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: webapp_django | |
jobs: | |
build_and_push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repo | |
uses: actions/checkout@v2 | |
- name: Create config directory and .env file | |
run: | | |
mkdir -p config | |
echo "DEBUG=False" >> config/.env | |
echo "SECRET_KEY=foo" >> config/.env | |
echo "DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1] *" >> config/.env | |
echo "SQL_ENGINE=django.db.backends.postgresql" >> config/.env | |
echo "POSTGRES_DB=${{ secrets.POSTGRES_DB }}" >> config/.env | |
echo "POSTGRES_USER=${{ secrets.POSTGRES_USER }}" >> config/.env | |
echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" >> config/.env | |
echo "SQL_HOST=db" >> config/.env | |
echo "SQL_PORT=5432" >> config/.env | |
echo "DATABASE=postgres" >> config/.env | |
echo "DOMAIN=localhost" >> config/.env | |
working-directory: . | |
- name: Display content of .env file | |
run: cat ./config/.env | |
- name: Build Docker image using Docker Compose | |
run: docker-compose -f docker-compose.yml build | |
- name: verify that all the container have been built | |
run: docker images | |
- name: LOG IN to container registry | |
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: set lower case owner name | |
run: | | |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} | |
env: | |
OWNER: '${{ github.repository_owner }}' | |
- name: Tag image | |
run: | | |
echo ${REGISTRY}/${OWNER_LC}/${IMAGE_NAME}:${{ github.run_number }} | |
docker tag ${IMAGE_NAME} ${REGISTRY}/${OWNER_LC}/${IMAGE_NAME}:latest | |
docker tag nginx_django ${REGISTRY}/${OWNER_LC}/nginx_django:latest | |
- name: List Docker images | |
run: docker images | |
- name: Push image to GitHub Container Registry | |
run: | | |
echo ${REGISTRY}/${OWNER_LC}/${{ env.IMAGE_NAME }}:latest | |
docker push ${REGISTRY}/${OWNER_LC}/${{ env.IMAGE_NAME }}:latest | |
docker push ${REGISTRY}/${OWNER_LC}/nginx_django:latest | |