-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
26 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,39 +15,57 @@ jobs: | |
deploy: | ||
name: Deploy app | ||
runs-on: ubuntu-latest | ||
env: | ||
GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }} | ||
GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }} | ||
GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }} | ||
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }} | ||
GTM_ID: ${{ secrets.GTM_ID }} | ||
NPMRC_TOKEN: ${{ secrets.NPMRC_TOKEN }} | ||
SENTRY_DSN_FRONTEND: ${{ secrets.SENTRY_DSN_FRONTEND }} | ||
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }} | ||
APP_ENV: test | ||
PDF_API_URL: ${{ secrets.PDF_API_URL}} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup SSH agent | ||
uses: webfactory/ssh-[email protected] | ||
- name: Set up SSH and deploy | ||
uses: appleboy/ssh-[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.TEST_STACK_SSH_KEY }} | ||
|
||
- name: Run Ansible playbook | ||
uses: dawidd6/action-ansible-playbook@v2 | ||
with: | ||
playbook: playbook.yml | ||
directory: ./tests/test-infrastructure | ||
host: ${{ secrets.TEST_STACK_SERVER_IP }} | ||
username: ec2-user | ||
key: ${{ secrets.TEST_STACK_SSH_KEY }} | ||
inventory: | | ||
[test_server] | ||
${{ secrets.TEST_STACK_SERVER_IP }} ansible_user=ec2-user | ||
options: | | ||
--verbose | ||
script: | | ||
REPO_URL="https://github.com/${{ github.repository }}" | ||
DEST_DIR="/opt/govtool" | ||
# Check if /opt/govtool exists | ||
if [ -d "$DEST_DIR" ]; then | ||
if [ -d "$DEST_DIR/.git" ]; then | ||
cd $DEST_DIR || exit | ||
echo "Updating repository..." | ||
git fetch --all | ||
git checkout --force "$GOVTOOL_TAG" | ||
else | ||
echo "Not a git repository. Re-cloning..." | ||
rm -rf "$DEST_DIR" | ||
git clone "$REPO_URL" "$DEST_DIR" | ||
cd "$DEST_DIR" || exit | ||
git checkout --force "$GOVTOOL_TAG" | ||
fi | ||
else | ||
echo "Directory does not exist. Cloning repository..." | ||
git clone "$REPO_URL" "$DEST_DIR" | ||
cd "$DEST_DIR" || exit | ||
git checkout --force "$GOVTOOL_TAG" | ||
fi | ||
# Execute the build-and-deploy.sh script | ||
cd $DEST_DIR/tests/test-infrastructure | ||
./build-and-deploy.sh update-images | ||
env: | ||
GOVTOOL_TAG: ${{ github.sha }} | ||
GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }} | ||
GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }} | ||
GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }} | ||
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }} | ||
GTM_ID: ${{ secrets.GTM_ID }} | ||
NPMRC_TOKEN: ${{ secrets.NPMRC_TOKEN }} | ||
SENTRY_DSN_FRONTEND: ${{ secrets.SENTRY_DSN_FRONTEND }} | ||
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }} | ||
APP_ENV: test | ||
PDF_API_URL: ${{ secrets.PDF_API_URL}} |