-
Notifications
You must be signed in to change notification settings - Fork 0
Add GitHub Actions workflow for Dokku deployments #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
9527cba
Add GitHub Actions workflow for Dokku deploys
VinneyJ f60cd34
Fix GitHub Actions disk exhaustion during validation
VinneyJ 28e28b8
Deploy Dokku from Docker Hub image
VinneyJ 593a506
Use a single Docker Hub to Dokku deployment flow
VinneyJ 215fe33
Enable deployment workflow test branch
VinneyJ 9858faa
Build deployment image on ARM runner
VinneyJ 21a55c1
Allow deployment test from workflow PR branch
VinneyJ cfe2f38
Set default Docker Hub image repository
VinneyJ 459d2c0
Add semantic version tags for Docker images
VinneyJ 48045ea
Load Dokku deploy key without ssh-agent
VinneyJ a535b5f
Validate Dokku deploy key before SSH
VinneyJ 583b81e
Use base64 encoded Dokku deploy key
VinneyJ 333d118
Support base64 or multiline Dokku deploy key
VinneyJ e10170c
Use Dokku action for ARM image deployment
VinneyJ d32b506
Simplify Dokku image deploy workflow
VinneyJ 2ea126d
Read runtime settings from environment
VinneyJ 5e0c835
Fix Django template backend setting
VinneyJ c87dd19
Add whitenoise runtime dependency
VinneyJ 9884535
Use non-manifest static files storage
VinneyJ e243bda
Collect static files in Docker image
VinneyJ cd52a20
Address PR review: simplify SECRET_KEY, update actions to latest vers…
VinneyJ 47c6721
Remove redundant Python setup and compileall steps from workflow
VinneyJ 0b6eaa2
Fix deploy_docker_image to pass single tag to Dokku
VinneyJ 06fda2b
Revert deploy_docker_image to use steps.meta.outputs.tags
VinneyJ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,43 +1,72 @@ | ||
| name: Deploy to EC2 | ||
| name: VI | Build and Deploy | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
| branches: | ||
| - main | ||
| - chore/dokku-github-actions | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: Image version to publish and deploy, for example 1.0.0 | ||
| required: false | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: "${{ github.workflow }} @ ${{ github.ref }}" | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| APP_NAME: ${{ secrets.DOKKU_APP_NAME }} | ||
| DOKKU_REMOTE_URL: ssh://dokku@${{ secrets.DOKKU_HOST }}/${{ secrets.DOKKU_APP_NAME }} | ||
| IMAGE_NAME: ${{ vars.DOCKERHUB_IMAGE || 'codeforafrica/vulnerability-index-tool' }} | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| name: Build, Push, and Deploy | ||
| runs-on: ubuntu-24.04-arm | ||
| environment: prod | ||
| timeout-minutes: 60 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install django psycopg2-binary boto3 requests beautifulsoup4 pandas numpy torch transformers peft scikit-learn joblib langdetect cleanlab python-dotenv | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| # Add your test commands here | ||
| python -m compileall . | ||
|
|
||
| - name: Deploy to EC2 | ||
| uses: appleboy/ssh-action@master | ||
| with: | ||
| host: ${{ secrets.EC2_HOST }} | ||
| username: ${{ secrets.EC2_USERNAME }} | ||
| key: ${{ secrets.EC2_PRIVATE_KEY }} | ||
| script: | | ||
| cd ~/Vulnerability_index_tool | ||
| git pull origin main | ||
| source venv/bin/activate | ||
| pip install -r requirements.txt | ||
| python manage.py migrate | ||
| sudo systemctl restart gunicorn # or your service name | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v4 | ||
|
|
||
| - name: Login to DockerHub | ||
| uses: docker/login-action@v4 | ||
| with: | ||
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
|
|
||
| - name: Docker meta | ||
| id: meta | ||
| uses: docker/metadata-action@v6 | ||
| with: | ||
| images: ${{ env.IMAGE_NAME }} | ||
|
|
||
| - name: Build and push Docker image | ||
| uses: docker/build-push-action@v7 | ||
| with: | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| context: . | ||
| file: ./Dockerfile | ||
| platforms: linux/arm64 | ||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
|
|
||
| - name: Push to Dokku | ||
| uses: dokku/github-action@v1.10.0 | ||
| with: | ||
| git_remote_url: ${{ env.DOKKU_REMOTE_URL }} | ||
| ssh_private_key: ${{ secrets.DOKKU_SSH_PRIVATE_KEY }} | ||
| deploy_docker_image: ${{ steps.meta.outputs.tags }} | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.