Skip to content

Merge pull request #439 from frontendnetwork/dependabot/github_action… #79

Merge pull request #439 from frontendnetwork/dependabot/github_action…

Merge pull request #439 from frontendnetwork/dependabot/github_action… #79

Workflow file for this run

# Default GitHub build&push workflow
# Docs: https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
name: Create and publish a Docker image
on:
push:
branches:
- main
- release
- staging
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-prod:
if: github.ref != 'refs/heads/staging'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
environment:
name: Production
url: https://vegancheck.me
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@cf8514a65188af1d4f94f8c28a7a4153af1088ce
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@0f8c876bafbf5dbce05c36682ec68e9a0274a48a
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Setup Production Env
run: cp .env.main .env
- name: Build and push Docker image
uses: docker/build-push-action@9311bf5263ae5b36f3ec67aff768790c6e2344ad
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-and-push-staging:
if: github.ref == 'refs/heads/staging'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
environment:
name: Staging
url: https://staging.vegancheck.me
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@cf8514a65188af1d4f94f8c28a7a4153af1088ce
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@0f8c876bafbf5dbce05c36682ec68e9a0274a48a
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Setup Staging Env
run: cp .env.development .env
- name: Display .env contents
run: cat .env
- name: Build and push Docker image
uses: docker/build-push-action@9311bf5263ae5b36f3ec67aff768790c6e2344ad
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}