Created
June 23, 2021 19:55
-
-
Save pi0neerpat/711ed1027eeb66735e457fa930cd707b to your computer and use it in GitHub Desktop.
RedwoodJS - Docker build action
This file contains hidden or 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
# Adapted from https://github.com/users/jeliasson/packages/container/package/redwoodjs-app-api-main | |
# Force redeploy | |
name: "redwoodjs-app-main" | |
on: | |
push: | |
branches: | |
- main | |
env: | |
# Build | |
# TODO: change to "production"? | |
NODE_ENV: "development" | |
RUNTIME_ENV: "main" | |
# Container Registry | |
CONTAINER_REGISTRY_HOSTNAME: ghcr.io | |
CONTAINER_REGISTRY_USERNAME: pi0neerpat | |
CONTAINER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
CONTAINER_REGISTRY_REPOSITORY: pi0neerpat | |
CONTAINER_REGISTRY_IMAGE_PREFIX: my-app-redwood | |
# Repository | |
GIT_DEPLOY_REPOSITORY_NAME: pi0neerpat/my-app | |
GIT_DEPLOY_REPOSITORY_BRANCH: main | |
GIT_DEPLOY_REPOSITORY_AUTHOR_NAME: pi0neerpat | |
GIT_DEPLOY_REPOSITORY_AUTHOR_EMAIL: [email protected] | |
GIT_DEPLOY_REPOSITORY_AUTHOR_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
# | |
# Build | |
# | |
build: | |
name: Build | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 10 | |
strategy: | |
fail-fast: true | |
matrix: | |
platform: [api, web] | |
include: | |
- platform: api | |
# TODO: Change this to the production database | |
# Name of Github secret | |
DATABASE_URL: __DEVELOPMENT_DATABASE_URL | |
- platform: web | |
steps: | |
# Checkout source code | |
- name: Checkout source code | |
uses: actions/checkout@v2 | |
# Setup Docker using buildx-action | |
- name: Setup Docker | |
uses: docker/setup-buildx-action@v1 | |
# Login to Docker Container Registry | |
- name: Docker login | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ env.CONTAINER_REGISTRY_HOSTNAME }} | |
username: ${{ env.CONTAINER_REGISTRY_USERNAME }} | |
password: ${{ env.CONTAINER_REGISTRY_PASSWORD }} | |
# Build Docker image with a :latest and :<git sha> tag | |
- name: Docker build | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
context: . | |
file: ./${{ matrix.platform }}/Dockerfile | |
build-args: | | |
NODE_ENV=${{ env.NODE_ENV }} | |
RUNTIME_ENV=${{ env.RUNTIME_ENV }} | |
DATABASE_URL=${{ secrets[matrix.DATABASE_URL] }} | |
tags: | | |
${{ env.CONTAINER_REGISTRY_HOSTNAME }}/${{ env.CONTAINER_REGISTRY_REPOSITORY }}/${{ env.CONTAINER_REGISTRY_IMAGE_PREFIX }}-${{ matrix.platform }}-${{ env.RUNTIME_ENV }}:latest | |
${{ env.CONTAINER_REGISTRY_HOSTNAME }}/${{ env.CONTAINER_REGISTRY_REPOSITORY }}/${{ env.CONTAINER_REGISTRY_IMAGE_PREFIX }}-${{ matrix.platform }}-${{ env.RUNTIME_ENV }}:${{ github.sha }} | |
# TODO: Add CD tooling here. See https://github.com/users/jeliasson/packages/container/package/redwoodjs-app-api-main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment