Skip to content

Commit

Permalink
feat: add workflow to build images (#299)
Browse files Browse the repository at this point in the history
Co-authored-by: Mrugesh Mohapatra <[email protected]>
  • Loading branch information
ojeytonwilliams and raisedadead authored Nov 8, 2023
1 parent eecabb0 commit afda8b6
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build

on:
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-22.04
environment: staging # Hardcoded for now. TODO: use a matrix?
strategy:
fail-fast: false
matrix:
node-version: [20.x]
site_tlds: ['dev']
apps: ['backend', 'frontend', 'cron']

steps:
- name: Checkout source code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: ${{ matrix.node-version }}

- name: Create a tagname
id: tagname
run: |
echo "tagname=$(git rev-parse --short HEAD)-$(date +%Y%m%d)-$(date +%H%M)" >> $GITHUB_ENV
- name: Build & Tag Images
# We pass NEXT_PUBLIC_STRAPI_BACKEND_URL as a build arg to all apps,
# even though only the frontend needs it. The other builds will ignore
# it.
run: |
docker build . \
--tag registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ matrix.site_tlds }}/publish-${{ matrix.apps }}:$tagname \
--tag registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ matrix.site_tlds }}/publish-${{ matrix.apps }}:latest \
--build-arg NEXT_PUBLIC_STRAPI_BACKEND_URL=${{ secrets.NEXT_PUBLIC_STRAPI_BACKEND_URL }} \
--file docker/${{ matrix.apps }}/Dockerfile
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}

- name: Log in to DigitalOcean Container Registry with short-lived credentials
run: doctl registry login --expiry-seconds 1200

- name: Push image to DigitalOcean Container Registry
run: |
docker push registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ matrix.site_tlds }}/publish-${{ matrix.apps }}:$tagname
docker push registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ matrix.site_tlds }}/publish-${{ matrix.apps }}:latest

0 comments on commit afda8b6

Please sign in to comment.