Created
July 9, 2020 18:34
-
-
Save mattstein/315847332a9449d2fbba3fc6064d9d51 to your computer and use it in GitHub Desktop.
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: Forge Deploy | |
on: | |
push: | |
branches: | |
# - master | |
- develop | |
jobs: | |
deploy: | |
name: Update dependencies + deploy to production | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Extract branch name | |
shell: bash | |
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | |
id: extract_branch | |
- name: Cache node modules | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Get Composer cache directory | |
id: composer-cache | |
run: | | |
echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- name: Cache Composer downloads | |
uses: actions/cache@v1 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-composer- | |
- name: Cache PHP dependencies | |
uses: actions/cache@v1 | |
with: | |
path: vendor | |
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} | |
- name: Configure PHP | |
uses: shivammathur/setup-php@master | |
with: | |
php-version: 7.4 | |
extensions: mbstring, bcmath | |
tools: composer, prestissimo, deployer | |
- name: Configure SSH | |
env: | |
SSH_AUTH_SOCK: /tmp/ssh_agent.sock | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.SSH_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null | |
ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" | |
- name: Build front end | |
run: npm ci && npm run prod | |
- name: Install Composer dependencies | |
env: | |
SSH_AUTH_SOCK: /tmp/ssh_agent.sock | |
run: composer install --no-interaction --prefer-dist --optimize-autoloader | |
- name: Run Deployer | |
env: | |
DOT_ENV: ${{ secrets.DOT_ENV }} | |
SSH_AUTH_SOCK: /tmp/ssh_agent.sock | |
run: deployer deploy -vv -n --branch=${{ steps.extract_branch.outputs.branch }} --revision=${{ github.sha }} ${{ steps.extract_branch.outputs.branch }} | |
- name: Nofity Slack success | |
if: success() | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
uses: voxmedia/github-action-slack-notify-build@v1 | |
with: | |
channel: automation | |
status: success | |
color: good | |
- name: Notify Slack failure | |
if: failure() | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
uses: voxmedia/github-action-slack-notify-build@v1 | |
with: | |
channel: automation | |
status: failed | |
color: danger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment