Skip to content

Commit 9afa479

Browse files
author
Nazarii
committed
Update github actions
1 parent 53363bd commit 9afa479

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ jobs:
2929
with:
3030
push: ${{ github.event_name != 'pull_request' }}
3131
context: .
32-
tags: ${{ env.DOCKER_IMAGE }},latest
32+
tags: |
33+
${{ env.DOCKER_IMAGE_REPO }}:latest
34+
${{ env.DOCKER_IMAGE_REPO }}:${{ github.sha::7 }}
3335
file: docker/prod/web/Dockerfile

.github/workflows/tests.yml

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,39 @@ concurrency:
1616
group: ${{ github.workflow }}-${{ github.ref }}
1717
cancel-in-progress: true
1818

19-
2019
jobs:
2120
build:
22-
name: "Build dev image"
21+
name: "Build and Push Dev Image"
2322
runs-on: ubuntu-latest
2423
steps:
2524
- name: Checkout Repo
2625
uses: actions/checkout@v4
2726
- name: Set environment docker tag
28-
run: echo "DOCKER_TAG=${GITHUB_SHA::6}" >> $GITHUB_ENV
27+
id: set-docker-tag
28+
run: |
29+
BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}")
30+
echo "DOCKER_TAG=${BRANCH_NAME}" >> $GITHUB_ENV
2931
- name: Set environment docker image
3032
run: echo "DOCKER_IMAGE=${{ env.DOCKER_IMAGE_REPO }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV
3133
- name: Set up Docker Buildx
3234
uses: docker/setup-buildx-action@v3
33-
- name: Build dev version and export for testing
34-
uses: docker/build-push-action@v5
35+
- name: Login to Docker Hub
36+
uses: docker/login-action@v3
37+
with:
38+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
39+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
40+
- name: Build and Push Dev Image with Cache
41+
uses: docker/build-push-action@v6
3542
with:
3643
context: .
44+
push: true
3745
tags: ${{ env.DOCKER_IMAGE }}
3846
file: docker/dev/web/Dockerfile
39-
outputs: type=docker,dest=/tmp/template.tar
40-
- name: Upload artifact
41-
uses: actions/upload-artifact@v3
42-
with:
43-
name: template-${{ env.DOCKER_TAG }}
44-
path: /tmp/template.tar
47+
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE }}
48+
cache-to: type=inline
49+
4550
test:
51+
name: "Run Tests"
4652
runs-on: ubuntu-latest
4753
needs: [ build ]
4854
env:
@@ -54,22 +60,17 @@ jobs:
5460
POSTGRES_PORT: 5432
5561
steps:
5662
- name: Set environment docker tag
57-
run: echo "DOCKER_TAG=${GITHUB_SHA::6}" >> $GITHUB_ENV
63+
run: |
64+
BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}")
65+
echo "DOCKER_TAG=${BRANCH_NAME}" >> $GITHUB_ENV
5866
- name: Set environment docker image
5967
run: echo "DOCKER_IMAGE=${{ env.DOCKER_IMAGE_REPO }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV
60-
- name: Download artifact
61-
uses: actions/download-artifact@v3
62-
with:
63-
name: template-${{ env.DOCKER_TAG }}
64-
path: /tmp
65-
- name: Load image
66-
run: |
67-
docker load --input /tmp/template.tar
68-
- name: Migration check
68+
- name: Pull Docker Image
69+
run: docker pull ${{ env.DOCKER_IMAGE }}
70+
- name: Migration Check
6971
run: docker run --entrypoint="" ${{ env.DOCKER_IMAGE }} python manage.py makemigrations --check
70-
- name: Tests
72+
- name: Run Tests
7173
run: docker run --entrypoint="" ${{ env.DOCKER_IMAGE }} pytest
72-
7374
services:
7475
postgres:
7576
image: postgres:15.1-alpine

0 commit comments

Comments
 (0)