Skip to content

Create .env file from GH actions secret, add util script to update th… #2

Create .env file from GH actions secret, add util script to update th…

Create .env file from GH actions secret, add util script to update th… #2

name: Build Production Image
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Create .env file from secret
run: echo "${{ secrets.PRODUCTION_ENV_FILE }}" > .env
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
build-args: |
ENVIRONMENT=production
tags: |
peterrauscher/solesearch-api:latest
peterrauscher/solesearch-api:${{ steps.get_version.outputs.VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max