This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
Update README.md #71
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 | |
# Controls when the workflow will run | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- 'main' | |
- 'Dockerfile' | |
- 'file-ingest-dev' | |
- 'change-prefix' | |
release: | |
types: | |
- created | |
jobs: | |
build-matrix: | |
strategy: | |
matrix: | |
os: [buildjet-2vcpu-ubuntu-2204-arm, ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
# Get the repository's code | |
- name: Checkout | |
uses: actions/checkout@v2 | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Cache NPM | |
uses: buildjet/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: npm | |
- name: Determine Platform | |
run: | | |
if [[ "${{ runner.arch }}" == "X64" ]]; then | |
echo "Runner is amd64" | |
echo "PLATFORM=amd64" >> $GITHUB_ENV | |
elif [[ "${{ runner.arch }}" == "ARM64" ]]; then | |
echo "Runner is arm64" | |
echo "PLATFORM=arm64" >> $GITHUB_ENV | |
fi | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
platforms: linux/${{ env.PLATFORM }} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: karyeet/mandarine:${{ env.PLATFORM }}-${{ github.ref_name }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-docker-multiarch: | |
runs-on: ubuntu-latest | |
needs: [build-matrix] | |
steps: | |
- name: Login to Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Create and push multiarch image | |
run: | | |
docker buildx imagetools create -t karyeet/mandarine:${GITHUB_REF_NAME} \ | |
karyeet/mandarine:arm64-${GITHUB_REF_NAME} \ | |
karyeet/mandarine:amd64-${GITHUB_REF_NAME} | |
- name: Push to latest | |
if: github.event_name == 'release' | |
run: | | |
echo "Pushing to latest tag" | |
docker buildx imagetools create -t karyeet/mandarine:latest \ | |
karyeet/mandarine:arm64-${GITHUB_REF_NAME} \ | |
karyeet/mandarine:amd64-${GITHUB_REF_NAME} |