Skip to content

Commit

Permalink
Update config and add deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Ndpnt committed Dec 11, 2024
1 parent ca0b3f6 commit 14ce0c3
Show file tree
Hide file tree
Showing 11 changed files with 11,337 additions and 17 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
name: Deploy

on:
push:
branches: [ main ]

jobs:
test:
uses: "./.github/workflows/test.yml"

deploy:
needs: [ test ]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Get target server hostname
id: get_hostname
uses: mikefarah/yq@master
with:
cmd: yq '.all.hosts.* | key' deployment/inventory.yml
- name: Get target server fingerprint
id: get_fingerprint
uses: mikefarah/yq@master
with:
repository: ambanum/OpenTermsArchive
- name: Install SSH key
cmd: yq '.all.hosts.*.ed25519_fingerprint' deployment/inventory.yml
- name: Set up SSH
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SERVER_SSH_KEY }}
known_hosts: ${{ secrets.SERVER_FINGERPRINT }}
- run: echo "${{ secrets.ANSIBLE_VAULT_KEY }}" > vault.key
known_hosts: ${{ steps.get_hostname.outputs.result }} ssh-ed25519 ${{ steps.get_fingerprint.outputs.result }}
- run: echo "${{ secrets.ANSIBLE_VAULT_KEY }}" > deployment/vault.key
- run: pip install --upgrade setuptools
- run: pip install 'ansible ~= 2.9'
- run: ansible-playbook ops/app.yml --inventory ops/inventories/production.yml --tags update-declarations --limit france_elections
- name: Install dependencies
working-directory: ./deployment
run: ansible-galaxy collection install -p ./ -r requirements.yml --force
- name: Deploy
working-directory: ./deployment
run: ansible-playbook ./ansible_collections/opentermsarchive/deployment/playbooks/deploy.yml
28 changes: 25 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ name: Validate declarations

on:
push:
branches-ignore:
- 'main'
pull_request:
types: [ opened, reopened ]
workflow_call:

jobs:
validate_schema:
Expand All @@ -12,18 +15,37 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
node-version: 16
- run: npm install
- run: npm run test:schema

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: npm run lint

validate_modified_declarations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
fetch-depth: 0 # fetch all history for all branches and tags
- uses: actions/setup-node@v2
with:
node-version: 14
node-version: 16
- run: npm install
- run: npm run test:modified
- name: Generate artifacts
if: ${{ failure() }}
run: npm run start:modified
- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: snapshots_and_versions
path: ./data
if-no-files-found: error
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.DS_Store
node_modules
package-lock.json
data
vault.key
48 changes: 48 additions & 0 deletions config/production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"@opentermsarchive/engine": {
"recorder": {
"versions": {
"storage": {
"git": {
"snapshotIdentiferTemplate": "https://github.com/OpenTermsArchive/france-elections-snapshots/commit/%SNAPSHOT_ID",
"repository": "git@github.com:OpenTermsArchive/france-elections-versions.git",
"path": "./data/versions"
}
}
},
"snapshots": {
"storage": {
"git": {
"repository": "git@github.com:OpenTermsArchive/france-elections-snapshots.git",
"path": "./data/snapshots"
}
}
}
},
"fetcher": {
"language": "en"
},
"notifier": {
"sendInBlue": {
"updatesListId": 861,
"updateTemplateId": 56
}
},
"logger": {
"timestampPrefix": false
},
"tracker": {
"githubIssues": {
"repository": "OpenTermsArchive/france-elections-declarations"
}
},
"dataset": {
"title": "france-elections",
"versionsRepositoryURL": "https://github.com/OpenTermsArchive/france-elections-versions"
},
"collection-api": {
"port": 3000,
"basePath": "/collection-api"
}
}
}
11 changes: 11 additions & 0 deletions deployment/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$ANSIBLE_VAULT;1.1;AES256
66663831663730303932353632313863636434656336333733353233323430346337333161313037
6165383434373636643634303965653835353233313562320a363566616665666362383930356662
34663639626539666334626161306137346462656434333561356433393834623965633165636635
6632316332313031360a366465633935323033663930303431363936656139643837386164646332
32613236303930633732303239653138623266333937346634383230643161393861616664373038
36666238646363616232643666343162376163623638613133616635623633613233643037393962
36306230393563653165613364656636653132326237363434363663376263316266626132313761
30643531616631333331623638343636613465666663623239646564366262333833663132616435
34383964326638306461653662346630326134653638663036656462383636373264613235616261
3130643938393738623465373434336331636161646662623164
12 changes: 12 additions & 0 deletions deployment/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ansible.cfg
[defaults]
roles_path = ./ansible_collections/opentermsarchive/deployment/roles
inventory = inventory.yml

# The two following lines allow to have human readable output
# Use the YAML callback plugin.
stdout_callback = yaml
# Use the stdout_callback when running ad-hoc commands.
bin_ansible_callbacks = true

vault_password_file = vault.key
7 changes: 7 additions & 0 deletions deployment/inventory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all:
hosts:
51.89.225.198:
ansible_user: debian
ed25519_fingerprint: AAAAC3NzaC1lZDI1NTE5AAAAIKKjqn0w980q4yeqogV0p06MQavEw7fzPR6rplT3kiLj
ota_source_repository: https://github.com/OpenTermsArchive/france-elections-declarations.git
ota_source_repository_branch: deploy-api
14 changes: 14 additions & 0 deletions deployment/pm2.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
apps: [
{
name: 'ota-collection-api',
script: 'npm',
args: 'run start:collection-api',
min_uptime: '10s',
max_restarts: 10,
restart_delay: 1000,
exponential_backoff_restart_delay: true,
log_date_format: "YYYY-MM-DDTHH:mm:ssZ"
}
],
};
4 changes: 4 additions & 0 deletions deployment/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
collections:
- name: opentermsarchive.deployment
version: 2.0.2
Loading

0 comments on commit 14ce0c3

Please sign in to comment.