-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: buildx | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
- 'development' | ||
- 'staging' | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
environment: ${{ github.ref_name }} | ||
steps: | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Setup docker context for buildx | ||
id: buildx-context | ||
run: docker context create builders || docker context use builders | ||
|
||
- name: Extract repository name | ||
id: extract_repo_name | ||
run: | | ||
repo_url=${{ github.repository }} | ||
repo_name=$(basename $repo_url) | ||
echo "REPO_NAME=${repo_name}" >> $GITHUB_ENV | ||
echo "REPO_NAME=${repo_name}" | ||
- name: set lower case owner name | ||
run: | | ||
echo "REPO_LC=${OWNER,,}" >>${GITHUB_ENV} | ||
env: | ||
OWNER: '${{ env.REPO_NAME }}' | ||
|
||
- name: set vars per branch | ||
id: vars | ||
run: | | ||
if [ "$GITHUB_REF_NAME" == 'master' ]; then | ||
echo "NEXT_PUBLIC_FAIROSHOST=https://fairos.fairdatasociety.org" >> "$GITHUB_ENV" | ||
echo "NEXT_PUBLIC_ETHERNA_INDEX_API_PATH=https://index.etherna.io/api/v0.2" >> "$GITHUB_ENV" | ||
echo "NEXT_PUBLIC_FAIRDRIVEHOST=https://fairdrive.fairdatasociety.org" >> "$GITHUB_ENV" | ||
echo "NEXT_PUBLIC_NAME=Fairdrive Photo" >> "$GITHUB_ENV" | ||
elif [ "$GITHUB_REF_NAME" == 'development' ]; then | ||
echo "NEXT_PUBLIC_FAIROSHOST=https://fairos.dev.fairdatasociety.org" >> "$GITHUB_ENV" | ||
echo "NEXT_PUBLIC_ETHERNA_INDEX_API_PATH=https://index.etherna.io/api/v0.2" >> "$GITHUB_ENV" | ||
echo "NEXT_PUBLIC_FAIRDRIVEHOST=https://fairdrive.dev.fairdatasociety.org" >> "$GITHUB_ENV" | ||
echo "NEXT_PUBLIC_NAME=Fairdrive Photo" >> "$GITHUB_ENV" | ||
fi | ||
- name: copy ca | ||
run: | | ||
sudo mkdir -p /etc/docker/certs.d/${{ secrets.REGISTRY_URL }} | ||
echo "${{ secrets.REGISTRY_CA }}" | sudo tee /etc/docker/certs.d/${{ secrets.REGISTRY_URL }}/ca.crt | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
endpoint: builders | ||
config-inline: | | ||
[registry."${{ secrets.REGISTRY_URL }}"] | ||
http = false | ||
insecure = true | ||
ca=["/etc/docker/certs.d/${{ secrets.REGISTRY_URL }}/ca.crt"] | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: true | ||
platforms: | | ||
linux/amd64 | ||
build-args: | | ||
"NEXT_PUBLIC_FAIROSHOST=${{ env.NEXT_PUBLIC_FAIROSHOST }}" | ||
"NEXT_PUBLIC_FAIRDRIVEHOST=${{ env.NEXT_PUBLIC_FAIRDRIVEHOST }}" | ||
"REACT_APP_FAIRDRIVEHOST=${{ env.REACT_APP_FAIRDRIVEHOST }}" | ||
"NEXT_PUBLIC_NAME=${{ env.NEXT_PUBLIC_NAME }}" | ||
"NEXT_PUBLIC_ETHERNA_INDEX_API_PATH=${{ env.NEXT_PUBLIC_ETHERNA_INDEX_API_PATH }}" | ||
"PORT=80" | ||
tags: ${{ secrets.REGISTRY_URL }}/${{ env.REPO_LC }}:${{ github.sha }} | ||
cache-from: type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ env.REPO_LC }}:buildcache | ||
cache-to: type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ env.REPO_LC }}:buildcache,mode=max | ||
|