Push Remote Dev #2439
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
name: Push Remote Dev | |
on: | |
push: | |
branches: | |
- 'dev-*' | |
delete: | |
branches: | |
- 'dev-*' | |
# https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
# Force using BuildKit instead of normal Docker, required so that metadata | |
# is written/read to allow us to use layers of previous builds as cache. | |
DOCKER_BUILDKIT: 1 | |
COMPOSE_DOCKER_CLI_BUILD: 1 | |
DOCKER_REPO: ${{ secrets.ECR_REPO }}/ | |
jobs: | |
create-update-dev: | |
name: deploy dev branch | |
runs-on: ubuntu-latest | |
if: github.repository == 'chanzuckerberg/napari-hub' | |
steps: | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-region: us-west-2 | |
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
role-duration-seconds: 1200 | |
- name: Login to ECR | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ secrets.ECR_REPO }} | |
- name: Set up docker build environment | |
run: | | |
if [[ ${#GITHUB_REF_NAME} -gt 32 ]]; then | |
echo "branch name: ${GITHUB_REF_NAME}, length ${#GITHUB_REF_NAME}, is $((${#GITHUB_REF_NAME} - 32)) characters too long, please use a branch name that's 32 characters or shorter" | |
exit 1 | |
else | |
echo $GITHUB_REF_NAME | tr '[:upper:]' '[:lower:]' | xargs -I {} -n 1 echo STACK_NAME={} >> $GITHUB_ENV | |
fi | |
- name: Create update dev | |
if: ${{ github.event_name == 'push' }} | |
uses: chanzuckerberg/github-actions/.github/actions/[email protected] | |
env: | |
ENV: dev | |
with: | |
stack-name: ${{ env.STACK_NAME }} | |
create-tag: "true" | |
tag: ${{ env.STACK_NAME }} | |
tfe-token: ${{ secrets.TFE_TOKEN }} | |
env: "dev" | |
operation: "create-or-update" | |
- name: Delete dev set up stack name | |
if: ${{ github.event_name == 'delete' && startsWith(github.event.ref, 'dev-') }} | |
run: | | |
echo ${{ github.event.ref }} | tr '[:upper:]' '[:lower:]' | xargs -I {} -n 1 echo DELETE_STACK_NAME={} >> $GITHUB_ENV | |
- name: Delete dev | |
if: ${{ github.event_name == 'delete' && startsWith(github.event.ref, 'dev-') }} | |
uses: chanzuckerberg/github-actions/.github/actions/[email protected] | |
env: | |
ENV: dev | |
with: | |
stack-name: ${{ env.DELETE_STACK_NAME }} | |
operation: "delete" | |
tfe-token: ${{ secrets.TFE_TOKEN }} | |
env: "dev" | |
# Runs behave tests for backend code | |
bdd-tests: | |
runs-on: ubuntu-latest | |
needs: create-update-dev | |
if: ${{ github.event_name == 'push' }} | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v2 | |
- name: Setup Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.9' | |
- name: Fetch test prefix | |
run: echo $GITHUB_REF_NAME | tr '[:upper:]' '[:lower:]' | xargs -I {} -n 1 echo PREFIX={} >> $GITHUB_ENV | |
- name: Run tests | |
working-directory: backend | |
run: | | |
pip install --upgrade pip | |
pip install -r bdd-test-requirements.txt | |
cd bdd_tests && python -m pytest |