Skip to content

Commit

Permalink
[ci] build: add docker image build
Browse files Browse the repository at this point in the history
  • Loading branch information
darkobas2 committed Jun 8, 2023
1 parent c63ca21 commit 1c9d896
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/buildx.yml
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

0 comments on commit 1c9d896

Please sign in to comment.