Skip to content

Commit

Permalink
[ci] build: docker image build
Browse files Browse the repository at this point in the history
  • Loading branch information
darkobas2 committed Jun 8, 2023
1 parent cbf1769 commit 98be527
Showing 1 changed file with 107 additions and 0 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/buildx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: buildx

on:
push:
branches:
- 'main'
- '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_FAIRDRIVEHOST=https://app.fairdrive.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_BEE_URL=https://bee-1.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_RPC_URL=https://sepolia.dev.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_CREATE_ACCOUNT_REDIRECT=https://create.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_NFT_GENERATOR_URL=https://nft.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_CONSENT_VIEWER=https://app.crviewer.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_BLOCKCHAIN_INFO=Sepolia" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_ENVIRONMENT=SEPOLIA" >> "$GITHUB_ENV"
elif [ "$GITHUB_REF_NAME" == 'development' ]; then
echo "NEXT_PUBLIC_FAIROSHOST=https://app.fairos.dev.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_FAIRDRIVEHOST=https://app.fairdrive.dev.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_BEE_URL=https://bee-1.dev.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_RPC_URL=https://sepolia.dev.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_CREATE_ACCOUNT_REDIRECT=https://create.dev.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_NFT_GENERATOR_URL=https://nft.dev.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_CONSENT_VIEWER=https://app.crviewer.dev.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_BLOCKCHAIN_INFO=Sepolia" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_ENVIRONMENT=SEPOLIA" >> "$GITHUB_ENV"
elif [ "$GITHUB_REF_NAME" == 'staging' ]; then
echo "NEXT_PUBLIC_FAIROSHOST=https://fairos.staging.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_FAIRDRIVEHOST=https://fairdrive.staging.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_BEE_URL=https://bee-1.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_RPC_URL=https://sepolia.dev.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_CREATE_ACCOUNT_REDIRECT=https://create.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_NFT_GENERATOR_URL=https://nft.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_CONSENT_VIEWER=https://app.crviewer.fairdatasociety.org" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_BLOCKCHAIN_INFO=Sepolia" >> "$GITHUB_ENV"
echo "NEXT_PUBLIC_ENVIRONMENT=SEPOLIA" >> "$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=${{ vars.NEXT_PUBLIC_FAIROSHOST }}"
"NEXT_PUBLIC_FAIRDRIVEHOST=${{ vars.NEXT_PUBLIC_FAIRDRIVEHOST }}"
"NEXT_PUBLIC_BEE_URL=${{ vars.NEXT_PUBLIC_BEE_URL }}"
"NEXT_PUBLIC_RPC_URL=${{ vars.NEXT_PUBLIC_RPC_URL }}"
"NEXT_PUBLIC_CREATE_ACCOUNT_REDIRECT=${{ vars.NEXT_PUBLIC_CREATE_ACCOUNT_REDIRECT }}"
"NEXT_PUBLIC_NFT_GENERATOR_URL=${{ vars.NEXT_PUBLIC_NFT_GENERATOR_URL }}"
"NEXT_PUBLIC_CONSENT_VIEWER=${{ vars.NEXT_PUBLIC_CONSENT_VIEWER }}"
"NEXT_PUBLIC_BLOCKCHAIN_INFO=${{ vars.NEXT_PUBLIC_BLOCKCHAIN_INFO }}"
"NEXT_PUBLIC_ENVIRONMENT=${{ vars.NEXT_PUBLIC_ENVIRONMENT }}"
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 98be527

Please sign in to comment.