Skip to content

Commit

Permalink
refactor: scripts/ci/pin-to-cluster.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Jul 28, 2021
1 parent 87c0b11 commit 9544654
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 23 deletions.
29 changes: 7 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,28 +200,13 @@ jobs:
id: cid-reader
run: echo "::set-output name=CID::$(tail -1 ./versions)"
- name: Pin new website to ipfs-websites.collab.ipfscluster.io
run: |
echo 'pin to cluster'
ipfs-cluster-ctl --enc=json \
--host "/dnsaddr/ipfs-websites.collab.ipfscluster.io" \
--basic-auth '${{ secrets.CLUSTER_USER }}:${{ secrets.CLUSTER_PASSWORD }}' \
pin add \
--pin-name="https://github.com/ipfs/distributions/commits/${{ github.sha }}" \
--no-status \
"${{ steps.cid-reader.outputs.CID }}"
while true; do
ipfs-cluster-ctl --enc=json \
--host "/dnsaddr/ipfs-websites.collab.ipfscluster.io" \
--basic-auth '${{ secrets.CLUSTER_USER }}:${{ secrets.CLUSTER_PASSWORD }}' \
status "${{ steps.cid-reader.outputs.CID }}" | tee cluster-pin-status
if [[ $(jq '.peer_map[].status' cluster-pin-status | grep '"pinned"' | wc -l) -ge 2 ]]; then
echo "Got 2 pin confirmations, finishing the workflow"
break
else
echo "(sleeping for 15 seconds)"
sleep 15
fi
done
run: ./scripts/ci/pin-to-cluster.sh
env:
PIN_CID: ${{ steps.cid-reader.outputs.CID }}
PIN_NAME: "https://github.com/ipfs/distributions/commits/${{ github.sha }}"
PIN_ADD_EXTRA_ARGS: ""
CLUSTER_USER: ${{ secrets.CLUSTER_USER }}
CLUSTER_PASSWORD: ${{ secrets.CLUSTER_PASSWORD }}
timeout-minutes: 60
- name: Update PR status with preview link
run: |
Expand Down
28 changes: 28 additions & 0 deletions scripts/ci/pin-to-cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -e

echo "::group::pin add"
ipfs-cluster-ctl --enc=json \
--host "/dnsaddr/ipfs-websites.collab.ipfscluster.io" \
--basic-auth "${CLUSTER_USER}:${CLUSTER_PASSWORD}" \
pin add \
--pin-name="${PIN_NAME}" \
--no-status $PIN_ADD_EXTRA_ARGS \
"PIN_CID"
echo "::endgroup::"

echo "::group::waiting until pinned"
while true; do
ipfs-cluster-ctl --enc=json \
--host "/dnsaddr/ipfs-websites.collab.ipfscluster.io" \
--basic-auth "${CLUSTER_USER}:${CLUSTER_PASSWORD}" \
status "PIN_CID" | tee cluster-pin-status
if [[ $(jq '.peer_map[].status' cluster-pin-status | grep '"pinned"' | wc -l) -ge 2 ]]; then
echo "Got 2 pin confirmations, finishing the workflow"
break
else
echo "(sleeping for 15 seconds)"
sleep 15
fi
done
echo "::endgroup::"
2 changes: 1 addition & 1 deletion scripts/ci/setup-ipfs.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ echo "::group::Preconnect to cluster peers"
echo '-> preconnect to cluster peers'
ipfs-cluster-ctl --enc=json \
--host "/dnsaddr/ipfs-websites.collab.ipfscluster.io" \
--basic-auth '${CLUSTER_USER}:${CLUSTER_PASSWORD}' \
--basic-auth "${CLUSTER_USER}:${CLUSTER_PASSWORD}" \
peers ls > cluster-peers-ls
for maddr in $(jq -r '.[].ipfs.addresses[]?' cluster-peers-ls); do
ipfs swarm connect "$maddr" || continue
Expand Down

0 comments on commit 9544654

Please sign in to comment.