Cloud deployment #5
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: Frontend CI | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
# When this action will be executed | |
on: | |
# Automatically trigger it when detected changes in repo | |
push: | |
branches: | |
- main | |
- prod | |
paths: | |
- "frontend/**" | |
- ".github/workflows/frontend_ci.yml" | |
pull_request: | |
branches: | |
- main | |
- prod | |
paths: | |
- "frontend/**" | |
- ".github/workflows/frontend_ci.yml" | |
# Allow manual trigger | |
workflow_dispatch: | |
permissions: | |
contents: read | |
issues: read | |
checks: write | |
pull-requests: write | |
env: | |
REGISTRY_ADDRESS: containers.deltares.nl | |
HARBOR_PROJECT: fair-data | |
TAG: ${{ github.ref == 'refs/heads/prod' && 'prod' || 'dev' }} | |
TARGET: ${{ github.ref == 'refs/heads/prod' && 'run-prod' || 'run-dev' }} | |
jobs: | |
build-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository to the runner | |
uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY_ADDRESS }} | |
username: ${{ secrets.HARBOR_USER }} | |
password: ${{ secrets.HARBOR_PASSWORD }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: frontend | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
target: ${{ env.TARGET }} | |
push: ${{ github.event_name != 'pull_request'}} # Don't push on pull requests, only on push | |
tags: | | |
${{ env.REGISTRY_ADDRESS }}/${{ env.HARBOR_PROJECT }}/frontend:${{ github.sha }} | |
${{ env.REGISTRY_ADDRESS }}/${{ env.HARBOR_PROJECT }}/frontend:${{ env.TAG }} |