Skip to content

build: add workflow to publish images to DOCR #1

build: add workflow to publish images to DOCR

build: add workflow to publish images to DOCR #1

Workflow file for this run

name: CI - Build Images
on:
workflow_dispatch:
workflow_run:
workflows: ['CI - Node.js']
types:
- completed
pull_request:
branches:
- 'main'
jobs:
build:
name: Build (Image)
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [20.x]
apps: [client, api, new-api]
site_tlds: [dev]
environment: staging
steps:
- name: Checkout Source Files
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- 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 Image
run: |
docker build \
--build-arg HOME_LOCATION=${{ vars.HOME_LOCATION }} \
--build-arg API_LOCATION=${{ vars.API_LOCATION }} \
--build-arg FORUM_LOCATION=${{ vars.FORUM_LOCATION }} \
--build-arg NEWS_LOCATION=${{ vars.NEWS_LOCATION }} \
--build-arg RADIO_LOCATION=${{ vars.RADIO_LOCATION }} \
--build-arg CLIENT_LOCALE=${{ vars.CLIENT_LOCALE }} \
--build-arg CURRICULUM_LOCALE=${{ vars.CURRICULUM_LOCALE }} \
--build-arg SHOW_LOCALE_DROPDOWN_MENU=${{ vars.SHOW_LOCALE_DROPDOWN_MENU }} \
--build-arg ALGOLIA_APP_ID=${{ vars.ALGOLIA_APP_ID }} \
--build-arg ALGOLIA_API_KEY=${{ vars.ALGOLIA_API_KEY }} \
--build-arg STRIPE_PUBLIC_KEY=${{ vars.STRIPE_PUBLIC_KEY }} \
--build-arg PAYPAL_CLIENT_ID=${{ vars.PAYPAL_CLIENT_ID }} \
--build-arg PATREON_CLIENT_ID=${{ vars.PATREON_CLIENT_ID }} \
--build-arg DEPLOYMENT_ENV=${{ vars.DEPLOYMENT_ENV }} \
--build-arg SHOW_UPCOMING_CHANGES=${{ vars.SHOW_UPCOMING_CHANGES }} \
--build-arg SHOW_NEW_CURRICULUM=${{ vars.SHOW_NEW_CURRICULUM }} \
--build-arg GROWTHBOOK_URI=${{ vars.GROWTHBOOK_URI }} \
--build-arg FREECODECAMP_NODE_ENV=${{ vars.FREECODECAMP_NODE_ENV }} \
--tag registry.digitalocean.com/${{ vars.DOCR_NAME }}/${{ matrix.site_tlds }}/learn-${{ matrix.apps }}:$tagname \
--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/${{ vars.DOCR_NAME }}/${{ matrix.site_tlds }}/learn-${{ matrix.apps }}:$tagname
docker push registry.digitalocean.com/${{ vars.DOCR_NAME }}/${{ matrix.site_tlds }}/learn-${{ matrix.apps }}:latest