Skip to content
This repository was archived by the owner on Mar 9, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/continuous-deployment-in-ec2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Continuous deployment in AWS instance

on:
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
env:
# mention the path where snipe-it project cloned
FILE-PATH: /home/ubuntu/Snipe-IT-GitHub-Actions
steps:
# https://github.com/rusrushal13/aws-ssm-send-command
- name: AWS SSM Send-Command
uses: rusrushal13/aws-ssm-send-command@master
id: ssm
with:
aws-region: ${{ secrets.AWS_REGION }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
targets: ${{ secrets.TARGETS }}
working-directory: ${{ env.FILE-PATH }}
# the below commands executes in the EC2 instance where already Snipe-IT is running.
# 1. fetch changes from remote repository.
# 2. pull the latest codes from main branch.
# 3. deploy the changes.
command: |
git fetch --all
git pull origin main
docker-compose up -d
comment: building docker containers

# Catch SSM outputs
- name: Get the outputs
run: echo "The Command id is ${{ steps.ssm.outputs.command-id }}"