Skip to content

Commit

Permalink
Update cd_action.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanYK authored Dec 18, 2023
1 parent 8248513 commit e4241ac
Showing 1 changed file with 14 additions and 37 deletions.
51 changes: 14 additions & 37 deletions .github/workflows/cd_action.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,24 @@
name: ci_action
name: cd_action

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
workflow_run:
workflows: ["cd_action"]
types:
- completed

jobs:

build:

runs-on: ubuntu-latest
runs-on: self-hosted

steps:

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- uses: actions/checkout@v3
- name: Build and push the Docker image

run:
docker build -t ${{ secrets.DOCKER_HUB_USER }}/sessions-project:githubactions ./src

docker push ${{ secrets.DOCKER_HUB_USER }}/sessions-project:githubactions
- name: Pull docker image
run: sudo docker pull ${{ secrets.DOCKER_HUB_USER }}/sessions-project:githubactions
- name: Delete old container
run: sudo docker rm -f sessions-project-container || true
- name: Run container
run: sudo docker run -d -p --name sessions-project-container ${{ secrets.DOCKER_HUB_USER }}/sessions-project:githubactions



- uses: actions/checkout@v2
- name: Install Python 3
uses: actions/setup-python@v1
with:
python-version: 3.10.13
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r src/requirements.txt
- name: Run tests with pytest
run:
cd ..

pytest

0 comments on commit e4241ac

Please sign in to comment.