Refactor environment variables in .env.template and Dockerfile #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish to Registry on Github push | |
env: | |
GITHUB_SHA: ${{ github.sha }} | |
REGISTRY_HOSTNAME: docker.io | |
REPOSITORY: ${{ secrets.DOCKER_REPOSITORY }} | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
defaults: | |
run: | |
working-directory: '.' | |
jobs: | |
setup-build-publish-deploy: | |
name: Setup, Build, and Publish | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Prepare | |
id: prep | |
run: | | |
TAG=$(echo $GITHUB_SHA | head -c7) | |
IMAGE="${REPOSITORY}/hs_discover" | |
echo ::set-output name=tagged_image::${IMAGE}:${TAG} | |
echo ::set-output name=tag::${TAG} | |
- name: create env file | |
run: | | |
touch .env | |
echo VUE_APP_BUCKET_URL_PUBLIC_PATH=${{ secrets.VUE_APP_BUCKET_URL_PUBLIC_PATH }} >> .env | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker Hub Login | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-single-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-single-buildx | |
- name: Build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.prep.outputs.tagged_image }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |