SECURITY-49: Add GHA workflows #659
Workflow file for this run
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
| name: Relation Engine test and deploy | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - ready_for_review | |
| jobs: | |
| run_tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: checkout git repo | |
| uses: actions/checkout@v4 | |
| - name: run tests | |
| shell: bash | |
| env: | |
| GITHUB_ACTIONS_CI: 1 | |
| run: | | |
| docker-compose build | |
| docker-compose run re_api sh scripts/run_tests.sh | |
| docker-compose down --remove-orphans | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: true | |
| docker_build_and_push: | |
| runs-on: ubuntu-latest | |
| needs: run_tests | |
| if: (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master') && github.event_name == 'push' && !contains(github.event.head_commit.message, 'skip_docker_build') | |
| steps: | |
| - name: checkout git repo | |
| uses: actions/checkout@v4 | |
| - name: copy VERSION to TAG_NAME | |
| shell: bash | |
| run: | | |
| mkdir -p .target | |
| cp VERSION .target/TAG_NAME | |
| - name: set env vars | |
| shell: bash | |
| run: | | |
| echo "DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV | |
| echo "BRANCH=$(git symbolic-ref --short HEAD)" >> $GITHUB_ENV | |
| echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
| - name: build and push to dockerhub | |
| uses: opspresso/action-docker@master | |
| with: | |
| args: --docker | |
| env: | |
| USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
| PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
| DOCKERFILE: "Dockerfile" | |
| IMAGE_NAME: "kbase/relation_engine_api" |