From 98be5272aa3433f24c225d9de1e8891469c3578e Mon Sep 17 00:00:00 2001 From: darkobas Date: Thu, 8 Jun 2023 10:53:41 +0200 Subject: [PATCH] [ci] build: docker image build --- .github/workflows/buildx.yml | 107 +++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 .github/workflows/buildx.yml diff --git a/.github/workflows/buildx.yml b/.github/workflows/buildx.yml new file mode 100644 index 00000000..c902af4a --- /dev/null +++ b/.github/workflows/buildx.yml @@ -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