Skip to content

deployment action

deployment action #1

Workflow file for this run

name: CI - Build and Deploy
on:
push:
branches:
- main
- devops/move-circleci-to-gha
jobs:
persist-checkout:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Store image tag
id: image_tag
run: echo "IMAGE_TAG=$(echo `git log -n1 --format='%h'`)" >> $GITHUB_ENV
- name: Persist environment
uses: actions/upload-artifact@v2
with:
name: env
path: $GITHUB_ENV
build:
needs: persist-checkout
runs-on: ubuntu-latest
steps:
- name: Download environment
uses: actions/download-artifact@v3
with:
name: env
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build django image
run: |
source $GITHUB_ENV
docker build -t ldssa/django:$IMAGE_TAG .
docker save -o django.tar ldssa/django:$IMAGE_TAG
- name: Upload Docker image
uses: actions/upload-artifact@v3
with:
name: django-image
path: django.tar
push:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download Docker image
uses: actions/download-artifact@v3
with:
name: django-image
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Push django image
run: |
docker load -i django.tar
docker push ldssa/django:$IMAGE_TAG