Skip to content

Commit

Permalink
Docker Published to GitHub (#13)
Browse files Browse the repository at this point in the history
## Goal

The goal of this PR is to publish docker images to GitHub

## Checklist

- [x] PR Self-Review and Commenting
- [x] Docs updated
- [x] Tests added

## How To Test the Changes

- Test Run:
https://github.com/frequency-chain/testnet-faucet/actions/runs/8527012881
- Package Details:
https://github.com/frequency-chain/testnet-faucet/pkgs/container/testnet-faucet

---------

Co-authored-by: Dmitri <4452412+demisx@users.noreply.github.com>
  • Loading branch information
wilwade and demisx authored Apr 3, 2024
1 parent 1138088 commit 9481bd2
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 83 deletions.
19 changes: 6 additions & 13 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SMF_CONFIG_NETWORK="rococo"
SMF_CONFIG_NETWORK="frequencyRococo"

SMF_CONFIG_PORT=5555
SMF_CONFIG_DEPLOYED_REF=local
Expand All @@ -9,26 +9,19 @@ SMF_CONFIG_DEPLOYED_REF=local
# 3. Click the "Help & About" tab (left side of the dialog).
# 4. Scroll to the bottom and click on <click to reveal> part of Access Token.
# Note: Keep the browser login active as the token will be invalidated once you logout
SMF_CONFIG_MATRIX_ACCESS_TOKEN="NotValidExampleToken"
# SMF_CONFIG_MATRIX_ACCESS_TOKEN="NotValidExampleToken"

# See https://github.com/paritytech/devops/wiki/Matrix%3A-Registering-a-Matrix-Bot for how to register a bot
# Note: The bot account needs to be created in SMF_BOT_MATRIX_SERVER
SMF_CONFIG_MATRIX_BOT_USER_ID="@NotValidExampleAccount:matrix.parity.io"
SMF_CONFIG_FAUCET_IGNORE_LIST=""
SMF_CONFIG_MATRIX_SERVER=https://m.parity.io
# SMF_CONFIG_MATRIX_BOT_USER_ID="@NotValidExampleAccount:matrix.parity.io"
# SMF_CONFIG_FAUCET_IGNORE_LIST=""
# SMF_CONFIG_MATRIX_SERVER=https://m.parity.io

# To get account mnemonic - create an account in https://polkadot.js.org/apps/#/accounts (save details in password manager)
# Prior creating, make sure to switch to according network (in case of westend - TEST WESTEND & PARACHAINS => Westend)
# To feed new account with test tokens, go to https://matrix.to/#/#westend_faucet:matrix.org and drip to new address
# some convenient for tests amount "!drip <address> <amount>"
SMF_CONFIG_FAUCET_ACCOUNT_MNEMONIC="this is a fake mnemonic"
SMF_CONFIG_FAUCET_ACCOUNT_MNEMONIC="//Alice"

# Only used with external access
SMF_CONFIG_RECAPTCHA_SECRET="6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe" # Public testing secret, will accept all tokens.

# Database
SMF_CONFIG_DB_HOST=localhost
SMF_CONFIG_DB_PORT=5432
SMF_CONFIG_DB_USERNAME=postgres
SMF_CONFIG_DB_PASSWORD=postgres
SMF_CONFIG_DB_DATABASE_NAME=faucet
50 changes: 50 additions & 0 deletions .github/workflows/merge-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Merge PR
concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true
on:
push:
branches:
- main

jobs:
publish-app-docker-image:
name: "Publish App Docker Image"

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Check Out Repo
uses: actions/checkout@v4

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

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=sha,prefix=,format=short
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/library/node:18.16.0-alpine
FROM docker.io/library/node:20-alpine

# uncomment to fix build on MacOS Apple Silicon chip
# RUN apk add --no-cache python3 make g++
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Generic Faucet for Substrate based chains
## Frequency Testnet Faucet

[![GitHub Issue Sync](https://github.com/paritytech/polkadot-testnet-faucet/actions/workflows/github-issue-sync.yml/badge.svg)](https://github.com/paritytech/polkadot-testnet-faucet/actions/workflows/github-issue-sync.yml)
Fork of [paritytech/polkadot-testnet-faucet](https://github.com/paritytech/polkadot-testnet-faucet)

## Development

Expand All @@ -12,9 +12,8 @@ yarn simple-git-hooks
```

#### start local database:
```bash
yarn dev:db
```

Uses sqlite file, no start needed.

#### run migrations:
```bash
Expand Down
13 changes: 0 additions & 13 deletions docker/docker-compose.rococo-external.yml

This file was deleted.

13 changes: 0 additions & 13 deletions docker/docker-compose.rococo.yml

This file was deleted.

4 changes: 1 addition & 3 deletions e2e/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@ SMF_BOT_DEPLOYED_TIME=local
# BACKEND
SMF_BACKEND_FAUCET_ACCOUNT_MNEMONIC="//Alice"
SMF_CONFIG_FAUCET_ACCOUNT_MNEMONIC="//Alice"
SMF_BACKEND_FAUCET_BALANCE_CAP=100
SMF_BACKEND_INJECTED_TYPES="{ \"Address\": \"AccountId\", \"LookupSource\": \"AccountId\" }"
SMF_BACKEND_NETWORK_DECIMALS=12
SMF_BACKEND_PORT=5555
# Local Zombienet relaychain node.
SMF_BACKEND_RPC_ENDPOINT="ws://host.docker.internal:9944/"
SMF_BACKEND_DEPLOYED_REF=local
SMF_BACKEND_DEPLOYED_TIME=local
SMF_BACKEND_EXTERNAL_ACCESS=true
Expand Down
32 changes: 1 addition & 31 deletions env.faucet.config.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,6 @@
{
"SMF": {
"CONFIG": {
"DB_HOST": {
"description": "database hostname",
"default": "localhost",
"mandatory": true,
"type": "string"
},
"DB_PORT": {
"description": "database port",
"default": 5432,
"mandatory": true,
"type": "number"
},
"DB_USERNAME": {
"description": "database username",
"default": "postgres",
"mandatory": true,
"type": "string"
},
"DB_PASSWORD": {
"description": "database password",
"default": "postgres",
"mandatory": true,
"masked": true,
"type": "string"
},
"DB_DATABASE_NAME": {
"description": "name of postgres database",
"default": "faucet",
"mandatory": true,
"type": "string"
},
"DEPLOYED_REF": {
"description": "git ref which of deployed app",
"default": "unset",
Expand All @@ -55,6 +24,7 @@
},
"MATRIX_BOT_USER_ID": {
"description": "your bot user id",
"default": "@:",
"regexp": "^@.*:.*$",
"type": "string"
},
Expand Down
5 changes: 1 addition & 4 deletions src/bot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ const deployedRef = config.Get("DEPLOYED_REF");
const networkName = config.Get("NETWORK");
const networkData = getNetworkData(networkName);

const ignoreList = config
.Get("FAUCET_IGNORE_LIST")
.split(",")
.map((item) => item.replace('"', ""));
const ignoreList = (config.Get("FAUCET_IGNORE_LIST") || "").split(",").map((item) => item.replace('"', ""));

// Show the ignore list at start if any
if (ignoreList.length > 0) {
Expand Down

0 comments on commit 9481bd2

Please sign in to comment.