Merge pull request #85 from JSD-0723/development #51
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
# main.yaml | |
name: Build, Test, and Update Data | |
on: | |
push: | |
branches: ['main'] | |
jobs: | |
test_and_update_data: | |
name: Run Jest Tests and Update Data | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
#- name: Set up Docker Compose | |
# run: docker-compose -f docker-compose.dependencies.yaml -f docker-compose.app.yaml up -d | |
- name: Run Jest Tests | |
run: | | |
docker-compose -f docker-compose.dependencies.yaml -f docker-compose.app.yaml run --rm app npm test | |
- name: Tear down Docker Compose | |
run: docker-compose -f docker-compose.dependencies.yaml -f docker-compose.app.yaml down | |
- name: Import Data into Clever Cloud Database | |
run: | | |
mysql -h$CLEVER_CLOUD_DB_HOST -u$CLEVER_CLOUD_DB_USER -p$CLEVER_CLOUD_DB_PASSWORD $CLEVER_CLOUD_DB_NAME < data_dump.sql | |
env: | |
CLEVER_CLOUD_DB_HOST: ${{ secrets.CLEVER_CLOUD_DB_HOST }} | |
CLEVER_CLOUD_DB_USER: ${{ secrets.CLEVER_CLOUD_DB_USER }} | |
CLEVER_CLOUD_DB_PASSWORD: ${{ secrets.CLEVER_CLOUD_DB_PASSWORD }} | |
CLEVER_CLOUD_DB_NAME: ${{ secrets.CLEVER_CLOUD_DB_NAME }} | |
push_to_registry: | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
needs: test_and_update_data | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: atallah0/backend-final-4-app | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |