-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from RockefellerArchiveCenter/workflow-updates
Migrate from Travis to GH Actions
- Loading branch information
Showing
4 changed files
with
170 additions
and
57 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
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- development | ||
- base | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: ${{ github.ref_name }} | ||
|
||
env: | ||
APPLICATION_NAME: ursa_major | ||
CONTAINER: ursa-major-web | ||
APPLICATION_PORT: 8005 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: Export secrets to environment variables | ||
uses: oNaiPs/secrets-to-env-action@v1.5 | ||
with: | ||
secrets: ${{ toJSON(secrets) }} | ||
|
||
- name: Clone deploy scripts | ||
run: git clone https://github.com/RockefellerArchiveCenter/deploy_scripts.git | ||
|
||
- name: Substitute environment variables | ||
uses: tvarohohlavy/inplace-envsubst-action@v1.0.0 | ||
with: | ||
files: | | ||
$APPLICATION_NAME/config.py.deploy | ||
.env.deploy | ||
appspec.yml.deploy | ||
deploy_scripts/create_apache_config.sh.deploy | ||
deploy_scripts/curl_index.sh.deploy | ||
deploy_scripts/curl_status_endpoint.sh.deploy | ||
deploy_scripts/install_dependencies_django.sh.deploy | ||
deploy_scripts/restart_apachectl.sh.deploy | ||
deploy_scripts/run_management_commands_django.sh.deploy | ||
deploy_scripts/set_permissions.sh.deploy | ||
deploy_scripts/stop_cron.sh.deploy | ||
- name: Rename deploy files | ||
run: | | ||
mv $APPLICATION_NAME/config.py.deploy $APPLICATION_NAME/config.py | ||
mv .env.deploy .env | ||
mv appspec.yml.deploy appspec.yml | ||
mv deploy_scripts/create_apache_config.sh.deploy deploy_scripts/create_apache_config.sh | ||
mv deploy_scripts/curl_index.sh.deploy deploy_scripts/curl_index.sh | ||
mv deploy_scripts/curl_status_endpoint.sh.deploy deploy_scripts/curl_status_endpoint.sh | ||
mv deploy_scripts/install_dependencies_django.sh.deploy deploy_scripts/install_dependencies_django.sh | ||
mv deploy_scripts/restart_apachectl.sh.deploy deploy_scripts/restart_apachectl.sh | ||
mv deploy_scripts/run_management_commands_django.sh.deploy deploy_scripts/run_management_commands_django.sh | ||
mv deploy_scripts/set_permissions.sh.deploy deploy_scripts/set_permissions.sh | ||
mv deploy_scripts/stop_cron.sh.deploy deploy_scripts/stop_cron.sh | ||
- name: Make deploy scripts executable | ||
run: chmod +x deploy_scripts/*.sh | ||
|
||
- name: Create deployment zip | ||
run: sudo deploy_scripts/make_zip_django.sh $DEPLOY_ZIP_DIR $DEPLOY_ZIP_NAME | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4.0.2 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | ||
role-to-assume: ${{ secrets.AWS_DEPLOY_ROLE }} | ||
role-skip-session-tagging: true | ||
role-duration-seconds: 900 | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Deploy to S3 | ||
run: aws s3 cp $DEPLOY_ZIP_DIR s3://$AWS_BUCKET_NAME --recursive | ||
|
||
- name: Deploy to AWS CodeDeploy | ||
run: aws deploy create-deployment | ||
--region ${{ secrets.AWS_REGION }} | ||
--application-name $APPLICATION_NAME | ||
--deployment-config-name CodeDeployDefault.OneAtATime | ||
--deployment-group-name $DEPLOYMENT_GROUP | ||
--s3-location bucket=$AWS_BUCKET_NAME,bundleType=zip,key=$DEPLOY_ZIP_NAME |
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- development | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: development | ||
|
||
env: | ||
APPLICATION_NAME: ursa_major | ||
CONTAINER: ursa-major-web | ||
APPLICATION_PORT: 8005 | ||
|
||
services: | ||
docker: | ||
image: docker:stable | ||
options: --privileged | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
$HOME/.cache/pip | ||
$HOME/.cache/pre-commit | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/*.lock') }} | ||
|
||
- name: Copy config file | ||
run: cp ${{ env.APPLICATION_NAME }}/config.py.example ${{ env.APPLICATION_NAME }}/config.py | ||
|
||
- name: Login to Docker | ||
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | ||
|
||
- name: Start Docker containers | ||
run: docker compose up -d | ||
|
||
- name: Wait for services to be ready | ||
run: ./wait-for-it.sh $CONTAINER:$APPLICATION_PORT -- docker compose exec -T $CONTAINER pip install coverage | ||
|
||
- name: Install pre-commit | ||
run: | | ||
pip install "pre-commit===2.13.0" | ||
pre-commit install | ||
- name: Run pre-commit checks | ||
run: pre-commit run --all-files --show-diff-on-failure | ||
|
||
- name: Run tests with coverage | ||
run: docker compose exec -T $CONTAINER coverage run manage.py test | ||
|
||
- name: Generate coverage report | ||
run: docker compose exec -T $CONTAINER coverage report --omit=*/migrations/* -m |
This file was deleted.
Oops, something went wrong.