2021-11-03 22:42:02 +00:00
|
|
|
name: "Deploy to nki-personal"
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
types:
|
|
|
|
- opened
|
|
|
|
- synchronize
|
|
|
|
- reopened
|
|
|
|
- labeled
|
|
|
|
jobs:
|
2022-05-31 16:54:14 +00:00
|
|
|
test:
|
|
|
|
runs-on: ubuntu-latest
|
2022-05-31 17:21:39 +00:00
|
|
|
name: Formatting Check
|
2022-05-31 16:54:14 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2.3.4
|
2023-04-19 11:53:06 +00:00
|
|
|
- uses: cachix/install-nix-action@v20
|
2022-05-31 16:54:14 +00:00
|
|
|
with:
|
|
|
|
extra_nix_config: |
|
|
|
|
# Enable flakes
|
|
|
|
experimental-features = nix-command flakes
|
|
|
|
- name: Run format check
|
|
|
|
run: |
|
|
|
|
nix fmt
|
|
|
|
if [ -z "$(git status --untracked-files=no --porcelain)" ]; then
|
|
|
|
echo "Formatted, clean"
|
|
|
|
else
|
|
|
|
echo "The following files are unformatted:"
|
|
|
|
git status
|
|
|
|
false
|
|
|
|
fi
|
2021-11-03 22:42:02 +00:00
|
|
|
deploy:
|
2021-11-07 18:55:44 +00:00
|
|
|
if: "github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'Deploy')"
|
2021-11-03 22:42:02 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: Deploy
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2.3.4
|
2023-05-19 13:29:44 +00:00
|
|
|
- name: Notify deployment starting
|
|
|
|
run: |
|
2023-05-19 13:41:12 +00:00
|
|
|
git show --no-patch | curl \
|
2023-05-19 13:32:25 +00:00
|
|
|
--fail-with-body \
|
2023-05-19 13:29:44 +00:00
|
|
|
-u "${{ secrets.NTFY_CREDS }}" \
|
|
|
|
-H "X-Title: Deployment to nki-personal-do started" \
|
2023-05-19 13:44:56 +00:00
|
|
|
-H "X-Priority: 1" \
|
2023-05-19 13:29:44 +00:00
|
|
|
-H "X-Tags: cloud" \
|
2023-05-19 13:44:56 +00:00
|
|
|
-H "Actions: view, Open Job on GitHub, ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
|
2023-05-19 13:41:12 +00:00
|
|
|
-d "Commit info:
|
|
|
|
" \
|
2023-05-19 13:34:57 +00:00
|
|
|
-d @- \
|
2023-05-19 13:29:44 +00:00
|
|
|
https://ntfy.nkagami.me/nki-personal-do
|
2021-11-03 22:42:02 +00:00
|
|
|
- name: Add SSH key
|
|
|
|
env:
|
|
|
|
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
|
|
|
|
run: |
|
|
|
|
mkdir -p /home/runner/.ssh
|
2023-05-17 12:14:56 +00:00
|
|
|
echo "${{ secrets.NIX_SECRETS_SSH_KEY }}" > /home/runner/.ssh/nix_secrets_key
|
2021-11-03 22:42:02 +00:00
|
|
|
echo "${{ secrets.NIX_DEPLOY_SSH_KEY }}" > /home/runner/.ssh/nix_deploy_key
|
|
|
|
chmod 600 /home/runner/.ssh/*
|
|
|
|
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
|
|
|
|
ssh-add /home/runner/.ssh/*
|
|
|
|
ssh-keyscan ${{ secrets.INSTANCE_IP }} >> /home/runner/.ssh/known_hosts
|
2023-04-19 11:53:06 +00:00
|
|
|
- uses: cachix/install-nix-action@v20
|
2021-11-03 22:42:02 +00:00
|
|
|
with:
|
2023-04-19 12:00:46 +00:00
|
|
|
extra_nix_config: |
|
|
|
|
# Enable flakes
|
|
|
|
experimental-features = nix-command flakes
|
|
|
|
# Deploy tokens
|
|
|
|
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
2021-11-03 22:42:02 +00:00
|
|
|
- name: Deploy with deploy-rs
|
|
|
|
env:
|
|
|
|
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
|
|
|
|
run: |
|
2023-05-17 12:29:35 +00:00
|
|
|
nix run github:serokell/deploy-rs -- . --hostname ${{ secrets.INSTANCE_IP }} -s -- -L
|
2023-05-19 13:29:44 +00:00
|
|
|
- name: Notify deployment succeeding
|
|
|
|
run: |
|
2023-05-19 13:41:12 +00:00
|
|
|
git show --no-patch | curl \
|
2023-05-19 13:32:25 +00:00
|
|
|
--fail-with-body \
|
2023-05-19 13:29:44 +00:00
|
|
|
-u "${{ secrets.NTFY_CREDS }}" \
|
|
|
|
-H "X-Title: Deployment to nki-personal-do succeeded" \
|
|
|
|
-H "X-Tags: tada,cloud" \
|
2023-05-19 13:44:56 +00:00
|
|
|
-H "Actions: view, Open Job on GitHub, ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
|
2023-05-19 13:41:12 +00:00
|
|
|
-d "Commit info:
|
|
|
|
" \
|
2023-05-19 13:34:57 +00:00
|
|
|
-d @- \
|
2023-05-19 13:29:44 +00:00
|
|
|
https://ntfy.nkagami.me/nki-personal-do
|
|
|
|
- name: Notify deployment failing
|
|
|
|
if: ${{ failure() }}
|
|
|
|
run: |
|
2023-05-19 13:41:12 +00:00
|
|
|
git show --no-patch | curl \
|
2023-05-19 13:32:25 +00:00
|
|
|
--fail-with-body \
|
2023-05-19 13:29:44 +00:00
|
|
|
-u "${{ secrets.NTFY_CREDS }}" \
|
|
|
|
-H "X-Title: Deployment to nki-personal-do failed" \
|
|
|
|
-H "X-Priority: 4" \
|
|
|
|
-H "X-Tags: warning,cloud" \
|
2023-05-19 13:44:56 +00:00
|
|
|
-H "Actions: view, Open Job on GitHub, ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
|
2023-05-19 13:41:12 +00:00
|
|
|
-d "Commit info:
|
|
|
|
" \
|
2023-05-19 13:34:57 +00:00
|
|
|
-d @- \
|
2023-05-19 13:29:44 +00:00
|
|
|
https://ntfy.nkagami.me/nki-personal-do
|
|
|
|
|