-
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 #49 from RockefellerArchiveCenter/github-workflows
GitHub workflows
- Loading branch information
Showing
6 changed files
with
147 additions
and
55 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,68 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- development | ||
- base | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
environment: | ||
name: ${{ github.ref_name }} | ||
|
||
env: | ||
APP_NAME: digitized_av_qc | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4.0.2 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
role-to-assume: ${{ secrets.AWS_DEPLOY_ROLE }} | ||
role-skip-session-tagging: true | ||
role-duration-seconds: 900 | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
uses: aws-actions/amazon-ecr-login@v2.0.1 | ||
with: | ||
registries: ${{ secrets.ECR_REGISTRIES }} | ||
|
||
- name: Set environment variables | ||
run: | | ||
echo "DATE=$(date +'%Y%m%dT%H%M%S')" >> $GITHUB_ENV | ||
- name: Build Docker image | ||
run: docker build -t ${{ env.APP_NAME }} --target build . | ||
|
||
- name: Tag and push latest to ECR | ||
if: github.ref == 'refs/heads/base' | ||
run: | | ||
docker tag ${{ env.APP_NAME }} "${{ secrets.AWS_ACCOUNT_ID }}".dkr.ecr."${{ secrets.AWS_REGION }}".amazonaws.com/"${{ env.APP_NAME }}":latest | ||
docker push "${{ secrets.AWS_ACCOUNT_ID }}".dkr.ecr."${{ secrets.AWS_REGION }}".amazonaws.com/"${{ env.APP_NAME }}":latest | ||
- name: Tag and push dev to ECR | ||
if: github.ref == 'refs/heads/development' | ||
run: | | ||
docker tag ${{ env.APP_NAME }} "${{ secrets.AWS_ACCOUNT_ID }}".dkr.ecr."${{ secrets.AWS_REGION }}".amazonaws.com/"${{ env.APP_NAME }}":dev | ||
docker push "${{ secrets.AWS_ACCOUNT_ID }}".dkr.ecr."${{ secrets.AWS_REGION }}".amazonaws.com/"${{ env.APP_NAME }}":dev | ||
- name: Tag and push versioned image to ECR | ||
if: github.ref == 'refs/heads/development' | ||
run: | | ||
docker tag ${{ env.APP_NAME }} "${{ secrets.AWS_ACCOUNT_ID }}".dkr.ecr."${{ secrets.AWS_REGION }}".amazonaws.com/"${{ env.APP_NAME }}":"${{ env.DATE }}"-"${{ github.sha }}" | ||
docker push "${{ secrets.AWS_ACCOUNT_ID }}".dkr.ecr."${{ secrets.AWS_REGION }}".amazonaws.com/"${{ env.APP_NAME }}":"${{ env.DATE }}"-"${{ github.sha }}" | ||
- name: Tag image for production (base branch) | ||
if: github.ref == 'refs/heads/base' | ||
run: | | ||
MANIFEST=$(aws ecr batch-get-image --registry-id ${{ secrets.AWS_ACCOUNT_ID }} --repository-name ${{ env.APP_NAME }} --image-ids imageTag=dev --output json | jq -c --join-output '.images[0].imageManifest') | ||
aws ecr put-image --registry-id ${{ secrets.AWS_ACCOUNT_ID }} --repository-name ${{ env.APP_NAME }} --image-tag prod --image-manifest "$MANIFEST" |
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,16 @@ | ||
name: 'Check Branch' | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- base | ||
|
||
jobs: | ||
check_branch: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check branch | ||
if: github.head_ref != 'development' | ||
run: | | ||
echo "ERROR: You can only merge to base from the development branch." | ||
exit 1 |
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,51 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- development | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
environment: | ||
name: development | ||
|
||
env: | ||
CONTAINER: web | ||
APPLICATION_NAME: digitized_av_qc | ||
APPLICATION_PORT: 80 | ||
|
||
services: | ||
docker: | ||
image: docker:stable | ||
options: --privileged | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
cache: 'pip' | ||
|
||
- 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: 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 | ||
run: docker compose exec -T $CONTAINER python manage.py test |
This file was deleted.
Oops, something went wrong.
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