chore: Adding sharp #32
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: Deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
check-files-changes: | |
name: Check files changes | |
outputs: | |
run_job: ${{ steps.check_files_changes.outputs.run_job }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Check files changes | |
id: check_files_changes | |
run: | | |
echo "=============== list modified files ===============" | |
git diff --name-only HEAD^ HEAD | |
echo "========== check paths of modified files ==========" | |
git diff --name-only HEAD^ HEAD > files.txt | |
while IFS= read -r file | |
do | |
echo $file | |
if [[ $file == *"compute/client"* ]]; then | |
echo "this modified file is in client directory" | |
echo "run_job=client" >> $GITHUB_OUTPUT | |
break | |
elif [[ $file == *"compute/server"* ]]; then | |
echo "this modified file is in server directory" | |
echo "run_job=server" >> $GITHUB_OUTPUT | |
break | |
fi | |
done < files.txt | |
client-ci: | |
needs: check-files-changes | |
if: ${{ needs.check-files-changes.outputs.run_job == 'client' }} | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./compute/client | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install | |
run: npm install | |
- name: Run Lint | |
run: npm run lint | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
${{ vars.DOCKER_HUB_USERNAME }}/${{ vars.DOCKERHUB_REPO }} | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
# set latest tag for main branch | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | |
type=sha | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup 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 | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./compute/client | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
server-ci: | |
needs: check-files-changes | |
if: ${{ needs.check-files-changes.outputs.run_job == 'server' }} | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./compute/server | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install | |
run: npm install | |
- name: Run Lint | |
run: npm run lint | |
- name: Run Unit Tests | |
run: npm run test | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
${{ vars.DOCKER_HUB_USERNAME }}/${{ vars.DOCKERHUB_REPO_SERVER }} | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
# set latest tag for main branch | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | |
type=sha | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup 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 | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./compute/server | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |