Skip to content

Commit

Permalink
Update github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazarii committed Sep 3, 2024
1 parent 53363bd commit 9afa479
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ jobs:
with:
push: ${{ github.event_name != 'pull_request' }}
context: .
tags: ${{ env.DOCKER_IMAGE }},latest
tags: |
${{ env.DOCKER_IMAGE_REPO }}:latest
${{ env.DOCKER_IMAGE_REPO }}:${{ github.sha::7 }}
file: docker/prod/web/Dockerfile
47 changes: 24 additions & 23 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,39 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:
build:
name: "Build dev image"
name: "Build and Push Dev Image"
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Set environment docker tag
run: echo "DOCKER_TAG=${GITHUB_SHA::6}" >> $GITHUB_ENV
id: set-docker-tag
run: |
BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}")
echo "DOCKER_TAG=${BRANCH_NAME}" >> $GITHUB_ENV
- name: Set environment docker image
run: echo "DOCKER_IMAGE=${{ env.DOCKER_IMAGE_REPO }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build dev version and export for testing
uses: docker/build-push-action@v5
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and Push Dev Image with Cache
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.DOCKER_IMAGE }}
file: docker/dev/web/Dockerfile
outputs: type=docker,dest=/tmp/template.tar
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: template-${{ env.DOCKER_TAG }}
path: /tmp/template.tar
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE }}
cache-to: type=inline

test:
name: "Run Tests"
runs-on: ubuntu-latest
needs: [ build ]
env:
Expand All @@ -54,22 +60,17 @@ jobs:
POSTGRES_PORT: 5432
steps:
- name: Set environment docker tag
run: echo "DOCKER_TAG=${GITHUB_SHA::6}" >> $GITHUB_ENV
run: |
BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}")
echo "DOCKER_TAG=${BRANCH_NAME}" >> $GITHUB_ENV
- name: Set environment docker image
run: echo "DOCKER_IMAGE=${{ env.DOCKER_IMAGE_REPO }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: template-${{ env.DOCKER_TAG }}
path: /tmp
- name: Load image
run: |
docker load --input /tmp/template.tar
- name: Migration check
- name: Pull Docker Image
run: docker pull ${{ env.DOCKER_IMAGE }}
- name: Migration Check
run: docker run --entrypoint="" ${{ env.DOCKER_IMAGE }} python manage.py makemigrations --check
- name: Tests
- name: Run Tests
run: docker run --entrypoint="" ${{ env.DOCKER_IMAGE }} pytest

services:
postgres:
image: postgres:15.1-alpine
Expand Down

0 comments on commit 9afa479

Please sign in to comment.