-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ci] add vars handling and push to swarm
- Loading branch information
Showing
3 changed files
with
195 additions
and
31 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 |
---|---|---|
|
@@ -11,8 +11,16 @@ jobs: | |
runs-on: ubuntu-latest | ||
environment: ${{ github.ref_name }} | ||
steps: | ||
- | ||
name: Set up QEMU | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set environment specific variables | ||
uses: jnus/[email protected] | ||
with: | ||
scope: ${{ github.ref_name }} | ||
configFile: '.github/workflows/variables.json' | ||
secrets: '${{ toJson(secrets.github_token) }}' | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Setup docker context for buildx | ||
|
@@ -33,30 +41,12 @@ jobs: | |
env: | ||
OWNER: '${{ env.REPO_NAME }}' | ||
|
||
- name: set vars per branch | ||
id: vars | ||
run: | | ||
if [ "$GITHUB_REF_NAME" == 'main' ]; then | ||
echo "NEXT_PUBLIC_FAIROSHOST=https://fairos.fairdatasociety.org" >> "$GITHUB_ENV" | ||
echo "NEXT_PUBLIC_GATEWAYURL=https://gateway.fairdatasociety.org" >> "$GITHUB_ENV" | ||
echo "NEXT_PUBLIC_GATEWAYTEMPLATE=https://gateway.fairdatasociety.org/bzz/{reference}/" >> "$GITHUB_ENV" | ||
echo "NEXT_PUBLIC_CONTRACT=0xc5caC9F4610fb874F54aF5B12c19Cc5fECF75469" >> "$GITHUB_ENV" | ||
echo "NEXT_PUBLIC_NAME=Fairdrive NFT" >> "$GITHUB_ENV" | ||
elif [ "$GITHUB_REF_NAME" == 'development' ]; then | ||
echo "NEXT_PUBLIC_FAIROSHOST=https://fairos.dev.fairdatasociety.org" >> "$GITHUB_ENV" | ||
echo "NEXT_PUBLIC_GATEWAYURL=https://gateway.fairdatasociety.org" >> "$GITHUB_ENV" | ||
echo "NEXT_PUBLIC_GATEWAYTEMPLATE=https://gateway.fairdatasociety.org/bzz/{reference}/" >> "$GITHUB_ENV" | ||
echo "NEXT_PUBLIC_CONTRACT=0xc5caC9F4610fb874F54aF5B12c19Cc5fECF75469" >> "$GITHUB_ENV" | ||
echo "NEXT_PUBLIC_NAME=Fairdrive NFT" >> "$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 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
endpoint: builders | ||
|
@@ -66,21 +56,20 @@ jobs: | |
insecure = true | ||
ca=["/etc/docker/certs.d/${{ secrets.REGISTRY_URL }}/ca.crt"] | ||
- | ||
name: Build and push | ||
- uses: bilberrry-infra/docker-build-args-action@master | ||
id: action | ||
with: | ||
includeVars: ${{ toJson(env) }} | ||
includeSecrets: ${{ toJson(secrets) }} | ||
|
||
- 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_GATEWAYURL=${{ env.NEXT_PUBLIC_GATEWAYURL }}" | ||
"NEXT_PUBLIC_GATEWAYTEMPLATE=${{ env.NEXT_PUBLIC_GATEWAYTEMPLATE }}" | ||
"NEXT_PUBLIC_NAME=${{ env.NEXT_PUBLIC_NAME }}" | ||
"NEXT_PUBLIC_CONTRACT=${{ env.NEXT_PUBLIC_CONTRACT }}" | ||
"PORT=80" | ||
tags: ${{ secrets.REGISTRY_URL }}/${{ env.REPO_LC }}:${{ github.sha }} | ||
build-args: ${{ steps.action.outputs.args }} | ||
tags: ${{ secrets.REGISTRY_URL }}/${{ env.REPO_LC }}:${{ github.sha }},${{ secrets.REGISTRY_URL }}/${{ env.REPO_LC }}:${{ github.ref_name }} | ||
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 | ||
|
||
|
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,92 @@ | ||
name: push to swarm | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: . | ||
strategy: | ||
matrix: | ||
node-version: [18.x] | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set environment specific variables | ||
uses: jnus/[email protected] | ||
with: | ||
scope: "swarm" | ||
configFile: '.github/workflows/variables.json' | ||
secrets: '${{ toJson(secrets.github_token) }}' | ||
|
||
- name: Cache node modules | ||
id: cache-npm | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
# npm cache files are stored in `~/.npm` on Linux/macOS | ||
path: ~/.npm | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | ||
name: List the state of node modules | ||
continue-on-error: true | ||
run: yarn list | ||
|
||
- name: install | ||
run: yarn install --frozen-lockfile | ||
- name: copy NEXT vars to .env | ||
run: | | ||
env |grep 'NEXT_PUBLIC' > .env | ||
- name: build | ||
run: yarn build-static | ||
env: | ||
CI: false | ||
NODE_OPTIONS: --openssl-legacy-provider | ||
|
||
- name: Upload | ||
id: swarm-upload | ||
uses: ethersphere/swarm-actions/upload-dir@latest | ||
with: | ||
bee-url: ${{ env.SWARM_URL }} | ||
dir: ./out | ||
index-document: index.html | ||
pin: true | ||
timeout: 200000 | ||
- name: update feed | ||
id: swarm-feed | ||
uses: ethersphere/swarm-actions/write-feed@latest | ||
#env: | ||
#SIGNER: SIGNER_${{ github.ref_name }} | ||
with: | ||
bee-url: ${{ env.SWARM_URL }} | ||
reference: ${{ steps.swarm-upload.outputs.reference }} | ||
topic: theapp | ||
signer: ${{ secrets.SIGNER }} | ||
- name: get CID | ||
id: swarm-cid | ||
uses: ethersphere/swarm-actions/reference-to-cid@latest | ||
with: | ||
reference: ${{ steps.swarm-feed.outputs.reference }} | ||
- name: print | ||
run: | | ||
echo "upload ref: " ${{ steps.swarm-upload.outputs.reference }} | ||
echo "feed ref: " ${{ steps.swarm-feed.outputs.reference }} | ||
echo "CID: " ${{ steps.swarm-cid.outputs.cid }} | ||
echo 'Feed Manifest: ${{ steps.swarm-feed.outputs.manifest }}' | ||
- name: purge cache | ||
env: | ||
TOKEN: '${{ secrets.purge_token }}' | ||
run: | | ||
curl -s ${{ env.PURGE_URL }}/deploy/purge?token=${{ secrets.purge_token }} -H "site: nft.fairdrive${{ env.DEPLOYMENT }}io" -H "uri: /" |
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,83 @@ | ||
{ | ||
"Variables": [ | ||
{ | ||
"Name": "DEPLOYMENT", | ||
"Value": ".", | ||
"Scope": { | ||
"Environment": [ | ||
"master", | ||
"main", | ||
"swarm" | ||
] | ||
} | ||
}, | ||
{ | ||
"Name": "DEPLOYMENT", | ||
"Value": ".dev.", | ||
"Scope": { | ||
"Environment": [ | ||
"development" | ||
] | ||
} | ||
}, | ||
{ | ||
"Name": "DEPLOYMENT", | ||
"Value": ".staging.", | ||
"Scope": { | ||
"Environment": [ | ||
"staging" | ||
] | ||
} | ||
}, | ||
{ | ||
"Name": "NEXT_PUBLIC_FAIROSHOST", | ||
"Value": "https://fairos#{DEPLOYMENT}fairdatasociety.org", | ||
"Scope": { | ||
"Environment": [ | ||
"master", | ||
"main", | ||
"development" | ||
] | ||
} | ||
}, | ||
{ | ||
"Name": "NEXT_PUBLIC_FAIROSHOST", | ||
"Value": "https://fairos#{DEPLOYMENT}fairdatasociety.org", | ||
"Scope": { | ||
"Environment": [ | ||
"swarm" | ||
] | ||
} | ||
}, | ||
{ | ||
"Name": "NEXT_PUBLIC_GATEWAYURL", | ||
"Value": "https://gateway.fairdatasociety.org", | ||
"Scope": {} | ||
}, | ||
{ | ||
"Name": "NEXT_PUBLIC_GATEWAYURL_TEMPLATE", | ||
"Value": "https://gateway.fairdatasociety.org/bzz/{reference}/", | ||
"Scope": {} | ||
}, | ||
{ | ||
"Name": "NEXT_PUBLIC_CONTRACT", | ||
"Value": "0xc5caC9F4610fb874F54aF5B12c19Cc5fECF75469", | ||
"Scope": {} | ||
}, | ||
{ | ||
"Name": "NEXT_PUBLIC_NAME", | ||
"Value": "Fairdrive NFT", | ||
"Scope": {} | ||
}, | ||
{ | ||
"Name": "PURGE_URL", | ||
"Value": "https://fairdrive#{DEPLOYMENT}fairdatasociety.org", | ||
"Scope": {} | ||
}, | ||
{ | ||
"Name": "SWARM_URL", | ||
"Value": "https://gateway#{DEPLOYMENT}fairdatasociety.org/proxy/", | ||
"Scope": {} | ||
} | ||
] | ||
} |