Change Ip #5
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 | |
on: | |
push: | |
branches: | |
- development | |
- master | |
jobs: | |
deploy-staging: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/development' | |
steps: | |
- name: Send Slack Message | |
uses: voxmedia/github-action-slack-notify-build@v1 | |
id: slack | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }} | |
with: | |
channel_id: ${{ vars.CHANNEL_ID }} | |
status: STARTING | |
color: warning | |
- name: Add Docker Cache Layer | |
uses: satackey/[email protected] | |
continue-on-error: true | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GIT_PAT }} | |
ref: development | |
# ... contents as before | |
- name: Set my SSH key and ssh-agent | |
uses: webfactory/[email protected] | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Use Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
run: yarn install | |
working-directory: src | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Run test | |
run: docker-compose run addressbook npm test | |
id: test | |
working-directory: src | |
continue-on-error: true | |
- name: Notify Failure | |
if: steps.test.outcome == 'failure' | |
uses: voxmedia/github-action-slack-notify-build@v1 | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }} | |
with: | |
channel_id: ${{ vars.CHANNEL_ID }} | |
message_id: ${{ steps.slack.outputs.message_id }} | |
status: FAILURE | |
color: danger | |
- name: Run playbook | |
uses: dawidd6/action-ansible-playbook@v2 | |
id: deploy | |
with: | |
# Required, playbook filepath | |
playbook: deploy.yml | |
# Optional, directory where playbooks live | |
directory: ./ansible | |
inventory: | | |
[staging] | |
165.227.139.136 | |
[web] | |
165.227.139.136 | |
# Optional, ansible configuration file content (ansible.cfg) | |
configuration: | | |
[defaults] | |
host_key_checking = True | |
log_path = /var/log/ansible.log | |
force_color = True | |
inventory = hosts | |
[ssh_connection] | |
ssh_args = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o [email protected],[email protected],ssh-ed25519,ssh-rsa | |
retries = 1 | |
# Optional, SSH private key | |
key: ${{secrets.SSH_PRIVATE_KEY}} | |
# Optional, additional flags to pass to ansible-playbook | |
options: | | |
--e env=staging | |
- name: Notify Failure | |
if: steps.deploy.outcome == 'failure' | |
uses: voxmedia/github-action-slack-notify-build@v1 | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }} | |
with: | |
channel_id: ${{ vars.CHANNEL_ID }} | |
message_id: ${{ steps.slack.outputs.message_id }} | |
status: FAILURE | |
color: danger | |
- name: Notify Success | |
if: steps.deploy.outcome == 'success' | |
uses: voxmedia/github-action-slack-notify-build@v1 | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }} | |
with: | |
channel_id: ${{ vars.CHANNEL_ID }} | |
message_id: ${{ steps.slack.outputs.message_id }} | |
status: SUCCESS | |
color: good | |