-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub Action to publish content.
- Loading branch information
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: 'Create SSH key' | ||
description: 'Setups SSH key for future use.' | ||
|
||
inputs: | ||
private-key: | ||
description: 'Private key contents (id_rsa)' | ||
required: true | ||
|
||
host-label: | ||
description: 'SSH name' | ||
default: 'server' | ||
|
||
host: | ||
description: 'Default connection host' | ||
required: true | ||
|
||
port: | ||
description: 'SSH port' | ||
default: '22' | ||
|
||
user: | ||
description: 'Default connection user' | ||
required: true | ||
|
||
strict-host-key-checking: | ||
description: 'Is host key should be strict checked' | ||
# Disabled by default for straight forward connection. | ||
default: 'no' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Create SSH key | ||
shell: bash | ||
run: | | ||
mkdir -p ~/.ssh; | ||
echo "${{ inputs.private-key }}" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
cat >>~/.ssh/config <<END | ||
Host ${{ inputs.host-label }} | ||
HostName ${{ inputs.host }} | ||
Port ${{ inputs.port }} | ||
User ${{ inputs.user }} | ||
IdentityFile ~/.ssh/id_rsa | ||
StrictHostKeyChecking ${{ inputs.strict-host-key-checking }} | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: CD | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- '[0-9]+.[0-9]+.[0-9]+' | ||
|
||
jobs: | ||
publish: | ||
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' | ||
name: Publish | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: production | ||
url: https://niklan.net | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Create SSH key | ||
uses: ./.github/actions/create-ssh-key | ||
with: | ||
private-key: ${{ secrets.cd_production_deploy_key }} | ||
user: ${{ secrets.cd_production_user }} | ||
host: ${{ secrets.cd_production_host }} | ||
port: ${{ secrets.cd_production_port }} | ||
|
||
- name: Sync content | ||
shell: bash | ||
run: | | ||
ssh server <<< " | ||
cd ${{ secrets.cd_production_content_directiory }} | ||
mkdir -p ${{ secrets.cd_production_deploy_files }} | ||
drush sql:dump \ | ||
--gzip \ | ||
--structure-tables-list=cache,cache_*,flood,history,queue,search_index,search_api_*,semaphore,sequences,sessions,watchdog \ | ||
> ${{ secrets.cd_production_deploy_directory }}/pre-deploy.sql.gz | ||
git fetch | ||
git checkout | ||
git pull | ||
drush niklan:sync:blog | ||
" |