Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
clementbiron authored Dec 12, 2023
0 parents commit 1b81a29
Show file tree
Hide file tree
Showing 17 changed files with 10,380 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
# Available options: daily, weekly or monthly
interval: "daily"
# Has to be formatted as hh:mm
time: "06:06"
# List of time zones: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
timezone: "Europe/Paris"
# Allow updates for Open Terms Archive engine
allow:
- dependency-name: "@opentermsarchive/engine"
# Open Terms Archive recommends to always add the collection maintainer team as a reviewer so they are notified of the update
reviewers:
- "OpenTermsArchive/demo"
# Avoid having too many open pull requests
open-pull-requests-limit: 1
42 changes: 42 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Deploy

on:
push:
branches: [ main ]

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

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

steps:
- uses: actions/checkout@v4
- 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:
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: ${{ 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'
- 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/engine/all.yml


70 changes: 70 additions & 0 deletions .github/workflows/first-time-setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: first-time-setup
run-name: Setup

on:
# Run when repo is generated from template
create:

# Only keep latest run of this workflow
concurrency:
group: first-time-setup
cancel-in-progress: true

permissions:
actions: write
checks: write
contents: write


jobs:
first-time-setup:
# Ensure this action is run only once
if: github.run_number == 1

runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Set environment variables
run: |
echo "REPOSITORY_OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV &&
echo "REPOSITORY_NAME=${{ github.event.repository.name }}" >> $GITHUB_ENV &&
echo "COLLECTION_NAME=$(echo ${{ github.event.repository.name }} | sed 's/-declarations//')" >> $GITHUB_ENV &&
echo "PLACEHOLDER=_ _ _ _ _ ✍️" >> $GITHUB_ENV
- name: Remove first time setup workflow
run: rm -f .github/workflows/first-time-setup.yml

- name: Remove declarations
run: rm -f declarations/*

- name: Update dependabot
run: |
sed -i "s|"OpenTermsArchive/demo"|"$REPOSITORY_OWNER/$REPOSITORY_NAME"|g" .github/dependabot.yml
- name: Update deployment inventory
run: |
sed -i -z -e "s|hosts:\n\([[:blank:]]*\).*:\n|hosts:\n\1$PLACEHOLDER:\n|g" deployment/inventory.yml &&
sed -i "s|ansible_user: .*|ansible_user: $PLACEHOLDER|g" deployment/inventory.yml &&
sed -i "s|ed25519_fingerprint: .*|ed25519_fingerprint: $PLACEHOLDER|g" deployment/inventory.yml
- name: Update config
run: |
sed -i "s|demo|$COLLECTION_NAME|g" config/production.json &&
sed -i "s|OpenTermsArchive|$REPOSITORY_OWNER|g" config/production.json
- name: Update README
run: |
sed -i "s|<!-- here goes your collection name -->.*<!-- until here -->|$COLLECTION_NAME|g" README.md &&
sed -i "s|OpenTermsArchive/demo-versions|$REPOSITORY_OWNER/$COLLECTION_NAME-versions|g" README.md &&
sed -i "s|<!-- customize to your context -->.*<!-- until here -->|$PLACEHOLDER|g" README.md
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Adapt template automatically"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Validate declarations

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

jobs:
validate_schema:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
- run: npm install
- run: npm run test:schema

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

validate_modified_declarations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history for all branches and tags
- uses: actions/setup-node@v3
with:
node-version: 20
- 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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
node_modules
data
vault.key
Loading

0 comments on commit 1b81a29

Please sign in to comment.