I have DO server and a Linode server and am connecting both of them to a GitHub Actions pipeline. I am testing out my ssh connection after reading the json config file and the DO server seems to work ok but the Linode doesn't and get the above error, does anyone know what the cause is? My private ssh key and public keys have both been added. My deploy-application.yaml file is below. Thank you for any help!
name: Deploy Application
on:
push:
branches: [main]
jobs:
laravel-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install composer dependencies
run: composer install --prefer-dist
- name: Install npm dependencies
run: npm install
- name: Run Mix
run: npm run production
- name: Prepare Laravel Application
run: |
cp .env.example .env
php artisan key:generate
- name: Run PHPUnit
run: php8.0 vendor/bin/phpunit
create-deployment-artifacts:
runs-on: ubuntu-latest
needs: [laravel-tests]
outputs:
deployment-matrix: ${{ steps.export-deployment-matrix.outputs.deployment-matrix }}
steps:
- uses: actions/checkout@v2
- name: Compile CSS and Javascript
run: |
npm install
npm run prod
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: "8.0"
extensions: mbstring, ctype, fileinfo, openssl, PDO, bcmath, json, tokenizer, xml, imagick, swoole, ext-dom, ext-curl
- name: Composer install
run: composer install -q --no-ansi --no-dev --no-interaction --no-scripts --no-progress --prefer-dist
- name: Create deployment artifact
env:
GITHUB_SHA: ${{ github.sha }}
run: tar -czf "${GITHUB_SHA}".tar.gz --exclude=*.git --exclude=node_modules *
- name: Store artifact for distribution
uses: actions/upload-artifact@v2
with:
name: app-build
path: ${{ github.sha }}.tar.gz
- name: Export deployment matrix
id: export-deployment-matrix
run: |
JSON="$(cat ./deployment-config.json)"
JSON="${JSON//'%'/'%25'}"
JSON="${JSON//$'\n'/'%0A'}"
JSON="${JSON//$'\r'/'%0D'}"
echo "::set-output name=deployment-matrix::$JSON"
testing-ssh-connection:
name: testing ssh connection
runs-on: ubuntu-latest
needs: [laravel-tests, create-deployment-artifacts]
strategy:
matrix:
server: ${{ fromJson(needs.create-deployment-artifacts.outputs.deployment-matrix) }}
steps:
- name: Testing ssh connection
uses: appleboy/ssh-action@master
with:
host: ${{ matrix.server.ip }}
username: ${{ matrix.server.username }}
key: ${{ secrets.SSH_KEY }}
port: ${{ matrix.server.port }}
script: |
echo this works
prepare-release-on-servers:
name: "${{ matrix.server.name }}: Prepare release"
runs-on: ubuntu-latest
needs: [laravel-tests, create-deployment-artifacts,
testing-ssh-connection
]
strategy:
matrix:
server: ${{ fromJson(needs.create-deployment-artifacts.outputs.deployment-matrix) }}
steps:
- uses: actions/download-artifact@v2
with:
name: app-build
- name: Upload
uses: appleboy/scp-action@master
with:
host: ${{ matrix.server.ip }}
username: ${{ matrix.server.username }}
key: ${{ secrets.SSH_KEY }}
port: ${{ matrix.server.port }}
source: ${{ github.sha }}.tar.gz
target: ${{ matrix.server.path }}/artifacts
- name: Extract archive and create directories
uses: appleboy/ssh-action@master
env:
GITHUB_SHA: ${{ github.sha }}
with:
host: ${{ matrix.server.ip }}
username: ${{ matrix.server.username }}
key: ${{ secrets.SSH_KEY }}
port: ${{ matrix.server.port }}
envs: GITHUB_SHA
script: |
pwd
mkdir -p "${{ matrix.server.path }}/releases/${GITHUB_SHA}"
chmod -R 0777 "${{ matrix.server.path }}/releases/${GITHUB_SHA}"
tar xzf ${{ matrix.server.path }}/artifacts/${GITHUB_SHA}.tar.gz -C "${{ matrix.server.path }}/releases/${GITHUB_SHA}"
rm -rf ${{ matrix.server.path }}/releases/${GITHUB_SHA}/storage
mkdir -p ${{ matrix.server.path }}/storage/{app,public,framework,logs}
mkdir -p ${{ matrix.server.path }}/storage/framework/{cache,sessions,testing,views}
chmod -R 0777 ${{ matrix.server.path }}/storage
run-before-hooks:
name: "${{ matrix.server.name }}: Before hook"
runs-on: ubuntu-latest
needs:
[
laravel-tests,
create-deployment-artifacts,
testing-ssh-connection,
prepare-release-on-servers,
]
strategy:
matrix:
server: ${{ fromJson(needs.create-deployment-artifacts.outputs.deployment-matrix) }}
steps:
- name: Run before hooks
uses: appleboy/ssh-action@master
env:
GITHUB_SHA: ${{ github.sha }}
RELEASE_PATH: ${{ matrix.server.path }}/releases/${{ github.sha }}
ACTIVE_RELEASE_PATH: ${{ matrix.server.path }}/current
STORAGE_PATH: ${{ matrix.server.path }}/storage
BASE_PATH: ${{ matrix.server.path }}
with:
host: ${{ matrix.server.ip }}
username: ${{ matrix.server.username }}
key: ${{ secrets.SSH_KEY }}
port: ${{ matrix.server.port }}
envs: GITHUB_SHA,RELEASE_PATH,ACTIVE_RELEASE_PATH,STORAGE_PATH,BASE_PATH
script: |
${{ matrix.server.beforeHooks }}
activate-release:
name: "${{ matrix.server.name }}: Activate release"
runs-on: ubuntu-latest
needs:
[
laravel-tests,
create-deployment-artifacts,
testing-ssh-connection,
prepare-release-on-servers,
run-before-hooks,
]
strategy:
matrix:
server: ${{ fromJson(needs.create-deployment-artifacts.outputs.deployment-matrix) }}
steps:
- name: Activate release
uses: appleboy/ssh-action@master
env:
GITHUB_SHA: ${{ github.sha }}
RELEASE_PATH: ${{ matrix.server.path }}/releases/${{ github.sha }}
ACTIVE_RELEASE_PATH: ${{ matrix.server.path }}/current
STORAGE_PATH: ${{ matrix.server.path }}/storage
BASE_PATH: ${{ matrix.server.path }}
LARAVEL_ENV: ${{ secrets.LARAVEL_ENV }}
with:
host: ${{ matrix.server.ip }}
username: ${{ matrix.server.username }}
key: ${{ secrets.SSH_KEY }}
port: ${{ matrix.server.port }}
envs: GITHUB_SHA,RELEASE_PATH,ACTIVE_RELEASE_PATH,STORAGE_PATH,BASE_PATH,ENV_PATH,LARAVEL_ENV
script: |
printf "%s" "$LARAVEL_ENV" > "${BASE_PATH}/.env"
ln -s -f ${BASE_PATH}/.env $RELEASE_PATH
ln -s -f $STORAGE_PATH $RELEASE_PATH
ln -s -n -f $RELEASE_PATH $ACTIVE_RELEASE_PATH
run-after-hooks:
name: "${{ matrix.server.name }}: After hook"
runs-on: ubuntu-latest
needs:
[
laravel-tests,
create-deployment-artifacts,
testing-ssh-connection,
prepare-release-on-servers,
run-before-hooks,
activate-release,
]
strategy:
matrix:
server: ${{ fromJson(needs.create-deployment-artifacts.outputs.deployment-matrix) }}
steps:
- name: Run after hooks
uses: appleboy/ssh-action@master
env:
GITHUB_SHA: ${{ github.sha }}
RELEASE_PATH: ${{ matrix.server.path }}/releases/${{ github.sha }}
ACTIVE_RELEASE_PATH: ${{ matrix.server.path }}/current
STORAGE_PATH: ${{ matrix.server.path }}/storage
BASE_PATH: ${{ matrix.server.path }}
with:
host: ${{ matrix.server.ip }}
username: ${{ matrix.server.username }}
key: ${{ secrets.SSH_KEY }}
port: ${{ matrix.server.port }}
envs: GITHUB_SHA,RELEASE_PATH,ACTIVE_RELEASE_PATH,STORAGE_PATH,BASE_PATH
script: |
${{ matrix.server.afterHooks }}
pwd
clean-up:
name: "${{ matrix.server.name }}: Clean up"
runs-on: ubuntu-latest
needs:
[
laravel-tests,
create-deployment-artifacts,
testing-ssh-connection,
prepare-release-on-servers,
run-before-hooks,
activate-release,
run-after-hooks,
]
strategy:
matrix:
server: ${{ fromJson(needs.create-deployment-artifacts.outputs.deployment-matrix) }}
steps:
- name: Run after hooks
uses: appleboy/ssh-action@master
env:
RELEASES_PATH: ${{ matrix.server.path }}/releases
ARTIFACTS_PATH: ${{ matrix.server.path }}/artifacts
with:
host: ${{ matrix.server.ip }}
username: ${{ matrix.server.username }}
key: ${{ secrets.SSH_KEY }}
port: ${{ matrix.server.port }}
envs: RELEASES_PATH
script: |
cd $RELEASES_PATH && ls -t -1 | tail -n +6 | xargs rm -rf
cd $ARTIFACTS_PATH && ls -t -1 | tail -n +6 | xargs rm -rf