Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade SLDR build and deploy workflows #33

Merged
merged 15 commits into from
Sep 16, 2024
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
24 changes: 22 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
name: Build
on:
workflow_call:
outputs:
artifact-id:
description: "The artifact id uploaded by this build"
value: ${{ jobs.build.outputs.artifact-id }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
artifact-id: ${{ steps.upload.outputs.artifact-id }}
steps:
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: pip install 'git+https://github.com/silnrsi/sldrtools'
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use cached sldr
id: cache-sldr
uses: actions/cache@v4
with:
path: |
flat
unflat
key: sldr-flattened-${{ hashFiles('sldr/**') }}

- name: Generate unflattened sldr
if: steps.cache-sldr.outputs.cache-hit != 'true'
run: ldmlflatten -o unflat -i sldr -a -c -g

- name: Generate flattened sldr
if: steps.cache-sldr.outputs.cache-hit != 'true'
run: ldmlflatten -o flat -i sldr -a -A -g

- uses: actions/upload-artifact@v4
id: upload
if: steps.cache-sldr.outputs.cache-hit != 'true'
with:
name: sldr
path: |
flat/
unflat/
compression-level: 9
29 changes: 17 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,51 @@ name: Deploy to server
on:
workflow_call:
inputs:
stage_to:
stage-to:
required: true
type: string
artifact-id:
required: true
type: string
secrets:
uploader_key:
uploader-key:
required: true
server_address:
server-address:
required: true
repository_dispatch_pat:
repository-dispatch-pat:
required: true

jobs:
deploy:
runs-on: ubuntu-latest
if: inputs.artifact-id
env:
RSYNC_OPTS: -aP --no-p --no-g --no-t --compress --del -e "ssh -o StrictHostKeyChecking=no"
steps:
# Install our private key for uploading deliverable
- uses: webfactory/ssh-agent@v0.7.0
- uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{secrets.uploader_key}}
ssh-private-key: ${{secrets.uploader-key}}
# Download the artefact
- uses: actions/download-artifact@v4
with:
name: sldr
# Upload results
- name: Upload flattened SLDR to /ldml-api/data/${{ inputs.stage }}
run: rsync ${{env.RSYNC_OPTS}} --chmod=Dug=rwx flat unflat ${{secrets.server_address}}/sites/s/ldml-api/data/${{ inputs.stage_to }}/
- name: Upload flattened SLDR to /ldml-api/data/${{ inputs.stage-to }}
run: rsync ${{env.RSYNC_OPTS}} --chmod=Dug=rwx flat unflat ${{secrets.server-address}}/sites/s/ldml-api/data/${{ inputs.stage-to }}/

dispatch:
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Trigger langtags rebuild
uses: peter-evans/repository-dispatch@v2
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.repository_dispatch_pat }}
token: ${{ secrets.repository-dispatch-pat }}
repository: silnrsi/langtags
event-type: sldr${{ endsWith(github.ref, '/release') && '-release' || ''}}-deployed
event-type: sldr-deployed
client-payload: >-
{
"release": "${{ endsWith(github.ref, '/release') }}"
"release": "${{ github.ref_name == 'release' }}",
"artifact-id": ${{ inputs.artifact-id }}
}
14 changes: 10 additions & 4 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ name: Flatten SLDR and publish release branch to production
on:
push:
paths:
- .github/workflows/**
- sldr/**
branches: [ release ]
pull_request:
types:
- closed
paths:
- .github/workflows/**
- sldr/**
branches: [ release ]

Expand All @@ -16,10 +20,12 @@ jobs:
# Deploy built artefacts to the secrets.UPLOAD_TARGET
deploy:
needs: build
if: github.event_name == 'push' || github.event.pull_request.merged == true
uses: ./.github/workflows/deploy.yml
with:
stage_to: sldr
stage-to: sldr
artifact-id: ${{ needs.build.outputs.artifact-id }}
secrets:
uploader_key: ${{ secrets.UPLOADER_SSH_KEY }}
server_address: ${{ secrets.UPLOAD_TARGET }}
repository_dispatch_pat: ${{ secrets.REPO_DISPATCH_TOKEN }}
uploader-key: ${{ secrets.UPLOADER_SSH_KEY }}
server-address: ${{ secrets.UPLOAD_TARGET }}
repository-dispatch-pat: ${{ secrets.REPO_DISPATCH_TOKEN }}
16 changes: 10 additions & 6 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: Flatten SLDR and publish to staging
name: Flatten SLDR and publish master to staging
on:
push:
paths:
- .github/workflows/**
- sldr/**
branches: [ master ]
branches: [ master, feat/*, fix/* ]
pull_request:
types:
- closed
paths:
- .github/workflows/**
- sldr/**
Expand All @@ -18,10 +20,12 @@ jobs:
# Deploy built artefacts to the secrets.UPLOAD_TARGET
deploy:
needs: build
if: github.event_name == 'push' || github.event.pull_request.merged == true
uses: ./.github/workflows/deploy.yml
with:
stage_to: sldr-staging
stage-to: sldr-staging
artifact-id: ${{ needs.build.outputs.artifact-id }}
secrets:
uploader_key: ${{ secrets.UPLOADER_SSH_KEY }}
server_address: ${{ secrets.UPLOAD_TARGET }}
repository_dispatch_pat: ${{ secrets.REPO_DISPATCH_TOKEN }}
uploader-key: ${{ secrets.UPLOADER_SSH_KEY }}
server-address: ${{ secrets.UPLOAD_TARGET }}
repository-dispatch-pat: ${{ secrets.REPO_DISPATCH_TOKEN }}
32 changes: 15 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
.*.sw?
# runtime litter
*.pyc
*~
**/__pycache__/
node_modules/
vendor_bower/
dev/
flat/
unflat/
cldrdata/
cldrflat/
temp/
results/
keyboards/
doc/*.rnc
sldr/*/*.orig

# Editors
*.bak
# build intermediates
*.egg-info/**
dist/
build/
/flat/**
/unflat/**

# dev environment
/.venv/
/.vscode/
*.code-workspace
*.env
*.secrets
*~
*.bak