Skip to content

v1.0.01: code update #3

v1.0.01: code update

v1.0.01: code update #3

---
# yamllint disable rule:line-length
name: Docker Build and Push
on:
pull_request:
types:
- closed
jobs:
build-and-push:
runs-on: ubuntu-latest
# yamllint disable rule:line-length
if: github.event.pull_request.merged == true && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev')
# yamllint enable rule:line-length
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get version from script
id: get_version
working-directory: ./
run: |
echo "version=$(python version.py)" >> $GITHUB_ENV
- name: Get deployment env
id: get_deployment
run: |
if [[ $GITHUB_REF == *"master"* ]]; then
DEPLOYMENT="prod"
elif [[ $GITHUB_REF == *"dev"* ]]; then
DEPLOYMENT="staging"
else
DEPLOYMENT=${GITHUB_REF#refs/heads/}
fi
echo "deployment=$DEPLOYMENT" >> $GITHUB_ENV
env
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PAT }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.production
push: true
# yamllint disable rule:line-length
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ vars.REPO_NAME }}:latest-${{ env.deployment }}
${{ secrets.DOCKER_USERNAME }}/${{ vars.REPO_NAME }}:${{ env.version }}-${{ env.deployment }}