Skip to content

Instantly share code, notes, and snippets.

@stefanpoensgen
Last active January 5, 2020 11:09
Show Gist options
  • Save stefanpoensgen/63507159112b561912bc67694ba79bee to your computer and use it in GitHub Desktop.
Save stefanpoensgen/63507159112b561912bc67694ba79bee to your computer and use it in GitHub Desktop.
GitHub Actions testing
name: Deploy Stage
on:
push:
branches:
- develop
jobs:
build:
runs-on: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Make envfile
uses: SpicyPizza/create-envfile@v1
with:
envkey_DATABASE_URL: '"${{ secrets.DATABASE_URL_STAGE }}"'
envkey_SHOPWARE_ENV: '"${{ secrets.SHOPWARE_ENV }}"'
envkey_ACCOUNT_USER: '"${{ secrets.ACCOUNT_USER }}"'
envkey_ACCOUNT_PASSWORD: '"${{ secrets.ACCOUNT_PASSWORD }}"'
envkey_SHOP_URL: '"${{ secrets.SHOP_URL }}"'
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: '7.2'
- name: Validate composer.json and composer.lock
run: composer validate
- name: Install dependencies
env:
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.ACCESS_TOKEN }}"}}'
run: composer install --prefer-dist --no-progress --no-suggest
- name: Copy file via ssh key
uses: appleboy/scp-action@master
env:
HOST: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
PORT: ${{ secrets.PORT }}
KEY: ${{ secrets.KEY }}
with:
source: "./,!./.git*,!./media,!./files,!.env.example,!./CHANGELOG.md,!./README.md"
target: "/httpdocs/stage/releases/${{ github.sha }}"
- name: Executing remote commands using ssh key
uses: appleboy/ssh-action@master
env:
SHA: ${{ github.sha }}
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
envs: SHA
script: |
cd /httpdocs/stage/ && ln -sfn releases/$SHA public
cd /httpdocs/stage/public && ln -s ../../../files files
cd /httpdocs/stage/public && ln -s ../../../media media
cd /httpdocs/stage/public && ./app/bin/post-update-stage.sh
cd /httpdocs/stage/releases && rm -rf `ls -t | tail -n +3`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment