some changes #3
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: 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 | |
notify-servers: | |
needs: docker | |
uses: fairdatasociety/ci_utils/.github/workflows/webhook.yml@main | |
secrets: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
wh_secret: ${{ secrets.WEBHOOK_SECRET }} | |
wh_url_d: ${{ secrets.WEBHOOK_URL_DEVELOPMENT }} | |
wh_url_m: ${{ secrets.WEBHOOK_URL_MASTER }} | |
with: | |
branch: ${{ github.ref_name }} |