Skip to content

Commit

Permalink
Test/deploy to production (#356)
Browse files Browse the repository at this point in the history
* Create reusable-docker-deploy.yml

creating a reusable deploy job

* Update reusable-docker-deploy.yml
  • Loading branch information
miha-at-ecmwf authored Oct 15, 2024
1 parent 7beb01c commit f199f7c
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/reusable-docker-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Reusable deploy

on:
workflow_dispatch:
inputs:
environment:
required: true
type: string
jobs:
deploy:
name: deploy image
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}

steps:
- name: checkout
uses: actions/checkout@v4
- name: install ssh keys
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ vars.SSH_HOST }} > ~/.ssh/known_hosts
- name: create .env
run: |
ssh ${{ vars.SSH_USER }}@${{ vars.SSH_HOST }} "cd /usr/config && \\
echo MONGO_DB_URI=${{ secrets.MONGO_URI }} | sudo tee .env && \\
echo MONGO_DB_NAME=${{ secrets.MONGO_DB_NAME }} | sudo tee -a .env && \\
echo OPEN_AQ_API_URL=${{ secrets.OPEN_AQ_API_URL }} | sudo tee -a .env && \\
echo OPEN_AQ_API_KEY=${{ secrets.OPEN_AQ_API_KEY }} | sudo tee -a .env && \\
echo CDSAPI_URL=${{ secrets.CDSAPI_URL }} | sudo tee -a .env && \\
echo CDSAPI_KEY=${{ secrets.CDSAPI_KEY }} | sudo tee -a .env && \\
exit"
- name: copy compose
run: |
scp deployment/compose.yaml ${{ vars.SSH_USER }}@${{ vars.SSH_HOST }}:/usr/config
- name: activate docker
run: |
ssh ${{ vars.SSH_USER }}@${{ vars.SSH_HOST }} "cd /usr/config && \\
echo ${{ secrets.GITHUB_TOKEN}} | sudo docker login --username ${{ github.actor }} --password-stdin ghcr.io
sudo docker compose pull
sudo docker compose up --force-recreate --build -d
sudo docker image prune -f
exit"
- name: clean up
run: |
rm -rf ~/.ssh

0 comments on commit f199f7c

Please sign in to comment.