Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: Build and Deploy

on:
push:
branches:
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
environment: mainnet
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix={{branch}}-

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BLOCKCHAIN_API_URL=${{ vars.BLOCKCHAIN_API_URL }}
BRIDGE_WALLET_ADDRESS=${{ vars.BRIDGE_WALLET_ADDRESS }}
EXPLORER_URL=${{ vars.EXPLORER_URL }}
GOVERNANCE_URL=${{ vars.GOVERNANCE_URL }}
INDEX_API_URL=${{ vars.INDEX_API_URL }}
IS_TESTNET=${{ vars.IS_TESTNET }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max

deploy:
needs: build
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
environment: mainnet
permissions:
packages: read
concurrency:
group: deploy-wallet
cancel-in-progress: false
env:
DOCKER_HOST: ssh://${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}

steps:
- name: Setup SSH
uses: MrSquaare/ssh-setup-action@2d028b70b5e397cf8314c6eaea229a6c3e34977a
with:
host: ${{ secrets.SSH_HOST }}
private-key: ${{ secrets.SSH_PRIVATE_KEY }}
private-key-name: deploy_key

- name: Log in to GHCR on remote host
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Deploy
run: |
IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:master"
NAME="wallet"

echo "Pulling $IMAGE..."
docker pull "$IMAGE"

echo "Stopping existing container..."
docker stop "$NAME" 2>/dev/null || true
docker rm "$NAME" 2>/dev/null || true

echo "Starting new container..."
docker run \
--detach \
--restart always \
--name "$NAME" \
--network core-network \
--expose 8000 \
--env HTTP_PORT="8000" \
--env VIRTUAL_HOST="${{ vars.DOMAIN }}" \
--env LETSENCRYPT_HOST="${{ vars.DOMAIN }}" \
--env LETSENCRYPT_EMAIL="${{ vars.LETSENCRYPT_EMAIL }}" \
--env NETWORK_ACCESS="external" \
"$IMAGE"

- name: Verify
run: |
sleep 10
STATE=$(docker inspect --format '{{.State.Status}}' "wallet")
if [ "$STATE" != "running" ]; then
echo "Container is not running (state: $STATE)"
docker logs --tail=50 "wallet"
exit 1
fi
echo "Container is running"

- name: Send Discord notification
if: always()
run: |
STATUS="${{ job.status }}"
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

if [ "$STATUS" == "success" ]; then
COLOR=3066993
TITLE="Deployment Successful"
else
COLOR=15158332
TITLE="Deployment Failed"
fi

curl -s -H "Content-Type: application/json" \
-X POST "${{ secrets.DISCORD_DEPLOYS_WEBHOOK }}" \
-d "{
\"username\": \"GitHub Actions\",
\"embeds\": [{
\"title\": \"$TITLE\",
\"color\": $COLOR,
\"fields\": [
{ \"name\": \"Service\", \"value\": \"Wallet\", \"inline\": true },
{ \"name\": \"Commit\", \"value\": \"\`${GITHUB_SHA:0:7}\`\", \"inline\": true },
{ \"name\": \"Workflow\", \"value\": \"[View logs]($RUN_URL)\", \"inline\": true }
],
\"timestamp\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",
\"footer\": { \"text\": \"Edge Wallet\" }
}]
}"
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wallet",
"version": "1.23.4",
"version": "1.23.5",
"description": "Web wallet for managing $EDGE",
"private": true,
"license": "GPL",
Expand Down
5 changes: 3 additions & 2 deletions src/components/Overviews.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<div class="transactions-items">
<TransactionsTable :limit="5" />
<TransactionsTable :limit="5" :receiveMetadata="receiveMetadata" />
</div>
</div>
</template>
Expand All @@ -14,7 +14,8 @@ export default {
name: 'Overviews',
components: {
TransactionsTable
}
},
props: ['receiveMetadata']
}
</script>

Expand Down
10 changes: 8 additions & 2 deletions src/views/Overview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
<div class="mt-35">
<h3>Recent transactions</h3>

<Overviews />
<Overviews :receiveMetadata="onTransactionsUpdate" />
</div>

<div class="w-full text-right mt-20">
<div class="w-full text-right mt-20" v-if="metadata.totalCount > 5">
<router-link to="/transactions" class="button button--success">View all</router-link>
</div>
</div>
Expand All @@ -40,6 +40,7 @@ export default {
title: 'Overview',
data: function () {
return {
metadata: { totalCount: 0 },
isTestnet: import.meta.env.VITE_IS_TESTNET === 'true'
}
},
Expand All @@ -50,6 +51,11 @@ export default {
NewsPromo,
RecentBlocks,
TestnetFaucet
},
methods: {
onTransactionsUpdate(metadata) {
this.metadata = metadata
}
}
}
</script>