Merge pull request #46 from incidentalhq/eng-75-create-status-updates… #43
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 frontend image | |
on: | |
push: | |
branches: [main] | |
paths: | |
- frontend/** | |
- .github/workflows/build-frontend.yml | |
jobs: | |
build-and-push-frontend: | |
environment: production-frontend | |
defaults: | |
run: | |
working-directory: frontend | |
env: | |
IMAGE_NAME: incidental/frontend | |
ECR_REPO: registry.digitalocean.com/incidental | |
VITE_API_BASE_URL: https://api.incidental.dev | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: "frontend/.nvmrc" | |
- name: Build frontend | |
run: | | |
npm install -g pnpm | |
pnpm install | |
pnpm build | |
- name: Run tests | |
run: | | |
pnpm vitest run | |
- name: Build image | |
uses: docker/build-push-action@v5 | |
with: | |
context: frontend | |
tags: ${{env.IMAGE_NAME}}:latest,${{env.ECR_REPO}}/${{env.IMAGE_NAME}}:latest,${{env.ECR_REPO}}/${{env.IMAGE_NAME}}:1.0.${{ github.run_number }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
outputs: type=docker | |
- name: Install doctl | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
- name: Push image | |
run: | | |
doctl registry login --expiry-seconds 300 | |
docker push ${ECR_REPO}/${IMAGE_NAME}:latest | |
docker push ${ECR_REPO}/${IMAGE_NAME}:1.0.${GITHUB_RUN_NUMBER} | |
- name: Slack Notification | |
uses: slackapi/[email protected] | |
with: | |
payload: | | |
{ | |
"text": "A new frontend has been pushed: 1.0.${{ github.run_number }}" | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} |