Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

add Infrastructure as a code section #211

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
71 changes: 70 additions & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,28 @@ on:
workflow_dispatch:

jobs:

create_runner:
name: create_runner
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.TERRAFORM }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /root/runners/solochain-nodes/terraform-apply-delete/
./plan.sh
./apply.sh

build:
if: contains( github.event.pull_request.labels.*.name, 'CI')
name: Create & push Docker image
runs-on: [ self-hosted, linux, x64, standalone ]

needs: create_runner
steps:

- uses: actions/checkout@v2
Expand Down Expand Up @@ -93,3 +110,55 @@ jobs:
script: |
cd /home/ops/
./validator.sh

remove_snapshot:
name: remove_snapshot
needs: deploy_2
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.TERRAFORM }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /root/runners/solochain-nodes/terraform-snapshot/
./delete.sh


create_snapshot:
name: create_snapshot
needs: remove_snapshot
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.TERRAFORM }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /root/runners/solochain-nodes/terraform-snapshot/
./plan.sh
./apply.sh


remove_runner:
name: remove_runner
needs: create_snapshot
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.TERRAFORM }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /root/runners/solochain-nodes/terraform-apply-delete/
./plan.sh
./destroy.sh
125 changes: 125 additions & 0 deletions .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: activate GH runner
on:

schedule:
- cron: "0 0 * * 0"

jobs:
create_runner:
name: create_runner
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.TERRAFORM }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /root/runners/solochain-nodes/terraform-apply-delete/
./plan.sh
./apply.sh

build:
if: contains( github.event.pull_request.labels.*.name, 'CI')
name: Create & push Docker image
runs-on: [ self-hosted, linux, x64, standalone ]
needs: create_runner
steps:

- uses: actions/checkout@v2
- name: Prepare
id: prep
run: |
TAG=$(echo $GITHUB_SHA | head -c7)
IMAGE="dappforce/subsocial-node"
echo ::set-output name=tagged_image::${IMAGE}:${TAG}
echo ::set-output name=tag::${TAG}

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

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-single-buildx

- name: Build production image
uses: docker/build-push-action@v2
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: docker/Dockerfile
push: true
tags: |
${{ steps.prep.outputs.tagged_image }}
dappforce/subsocial-node:activation
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

remove_snapshot:
name: remove_snapshot
needs: build
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.TERRAFORM }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /root/runners/solochain-nodes/terraform-snapshot/
./delete.sh

create_snapshot:
name: create_snapshot
needs: remove_snapshot
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.TERRAFORM }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /root/runners/solochain-nodes/terraform-snapshot/
./plan.sh
./apply.sh


remove_runner:
name: remove_runner
needs: create_snapshot
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.TERRAFORM }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /root/runners/solochain-nodes/terraform-apply-delete/
./plan.sh
./destroy.sh