-
-
Save kangaroodev/a4fb011a4aac6c08da6b214e4b52bccc to your computer and use it in GitHub Desktop.
Deployment with Github Actions
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: CI-CD | |
on: | |
push: | |
branches: | |
- production | |
jobs: | |
deploy: | |
name: Deploy to Production | |
runs-on: ubuntu-latest | |
steps: | |
# - name: View the github context | |
# run: echo "$GITHUB_CONTEXT" | |
# env: | |
# GITHUB_CONTEXT: ${{ toJson(github) }} | |
- name: Start deployment | |
uses: tallyb/deployments@0.5.0 | |
id: deployment | |
with: | |
step: start | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: Production | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup node | |
uses: actions/setup-node@v2-beta | |
with: | |
node-version: 14 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 7.3 | |
tools: composer:v1 | |
extensions: mbstring, intl | |
- name: Get composer cache directory | |
id: composer-cache | |
run: | | |
echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- name: Restore composer cache | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-composer- | |
- name: Install composer | |
run: composer install --no-interaction --no-ansi --optimize-autoloader --no-progress --prefer-dist | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Restore yarn cache | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Build JS and CSS | |
run: yarn pipeline | |
- name: Deploy website | |
uses: musps/action-deployer-php@v0.1.0 | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }} | |
with: | |
args: deploy | |
- name: Update deployment status | |
uses: tallyb/deployments@0.5.0 | |
if: always() | |
with: | |
step: finish | |
token: ${{ secrets.GITHUB_TOKEN }} | |
status: ${{ job.status }} | |
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | |
env_url: ${{ github.event.repository.homepage }} | |
- name: Slack notification | |
uses: 8398a7/action-slack@v3 | |
if: always() | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
with: | |
status: ${{ job.status }} | |
text: '*Deployment ${{ job.status }}:* <${{ github.event.repository.git_url }}|${{ github.event.repository.name }}> to ${{ github.event.repository.homepage }}' | |
job_name: Deploy to Production | |
author_name: <${{ github.event.sender.html_url }}|${{ github.event.head_commit.committer.name }}> | |
fields: commit,message,took | |
github_token: ${{ secrets.GITHUB_TOKEN }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment