chore: add cors to fastify #45
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: Docker CI/CD | |
on: | |
push: | |
branches: | |
- '*' | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Build and test Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
load: true | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | |
tags: test-image:${{ github.sha }} | |
- name: Test application health | |
run: | | |
docker run -d -p 8080:8080 -e SERVER_BEARER_TOKEN=test-token -e ALLOWED_PROJECTS=1000 --name test-container test-image:${{ github.sha }} | |
sleep 5 | |
chmod +x ./test/test_script.sh | |
./test/test_script.sh test-token || (docker logs test-container && exit 1) | |
deploy: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push Docker image for main branch | |
if: github.ref == 'refs/heads/main' | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: | | |
communityfirst/comape-cloud-client:latest | |
communityfirst/comape-cloud-client:${{ github.sha }} | |
- name: Build and push Docker image for other branches | |
if: github.ref != 'refs/heads/main' | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: | | |
communityfirst/comape-cloud-client:${{ github.sha }} | |
communityfirst/comape-cloud-client:${{ github.ref_name }} |