deploy main to staging #98
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
name: Deploy | |
run-name: >- | |
deploy ${{ github.ref_name }} to ${{ github.event_name == 'workflow_dispatch' && inputs.target || 'staging' }} | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
target: | |
description: Deployment target | |
required: true | |
type: environment | |
workflow_run: | |
workflows: [Code Quality] | |
types: [completed] | |
branches: [main] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
prepare: | |
name: Prepare | |
# uses: creasico/laravel-project/.github/workflows/prepare.yml@main | |
uses: ./.github/workflows/prepare.yml | |
secrets: inherit | |
with: | |
target: ${{ github.event_name == 'workflow_dispatch' && inputs.target || 'staging' }} | |
deploy: | |
runs-on: ubuntu-latest | |
name: Deploy to ${{ needs.prepare.outputs.target-env }} | |
needs: prepare | |
environment: | |
name: ${{ needs.prepare.outputs.target-env }} | |
url: ${{ env.APP_URL }} | |
env: | |
APP_ENV: ${{ needs.prepare.outputs.target-env }} | |
APP_URL: ${{ needs.prepare.outputs.target-url }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.1 | |
extensions: curl, intl, libxml, mbstring, pcntl, ssh2, zip | |
tools: composer:v2 | |
coverage: none | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Cache Composer dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ needs.prepare.outputs.composer-cache }} | |
key: php-8.1-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: php-8.1-composer- | |
- name: Download assets | |
id: download | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-${{ env.APP_ENV }} | |
path: public | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-interaction --no-progress --ansi | |
- name: Deploy | |
uses: deployphp/action@master | |
with: | |
private-key: ${{ secrets.DEPLOY_SSH_RSAKEY }} | |
ssh-config: ${{ secrets.DEPLOY_SSH_CONFIG }} | |
verbosity: '' | |
dep: deploy -f scripts/deploy.php env=${{ env.APP_ENV }} --branch ${{ github.ref_name }} |