Running Tiller Backend CI #21
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: Tiller Backend CI | |
run-name: Running Tiller Backend CI | |
on: | |
push: | |
branches: [main, master] | |
pull_request: | |
branches: [main, master] | |
workflow_dispatch: | |
jobs: | |
run_tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.8] | |
defaults: | |
run: | |
working-directory: ./backend | |
steps: | |
- name: checkout the code | |
uses: actions/checkout@v4 | |
- name: Notify the user | |
run: echo "Hello @${{github.repository_owner}}, code checked successfully." | |
shell: bash | |
- name: setup python environment | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{matrix.python-version}} | |
- name: install dependecies | |
run: | | |
pip install --upgrade pip | |
pip install -r requirements.txt | |
echo "@${{github.repository_owner}}, dependencies installed successfully" | |
shell: bash | |
- name: echo workspace | |
run: echo ${{github.workspace}} | |
shell: bash | |
- name: run the tests | |
run: | | |
flask tests | |
shell: bash | |
build_and_pub: | |
needs: run_tests | |
runs-on: [ubuntu-latest] | |
env: | |
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}} | |
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} | |
IMAGE_NAME: tiller-backend:latest | |
steps: | |
- name: checkout the code | |
uses: actions/checkout@v4 | |
- name: login to docker hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{env.DOCKER_USERNAME}} | |
password: ${{env.DOCKER_PASSWORD}} | |
- name: generate a unique tag for the image | |
id: generate-tag | |
# run: echo "::set-output name=TAG::latest-$(date +%Y%m%d%H%M%S)" | |
run: echo "::set-output name=TAG::latest-$(date +%Y%m%d%H)" | |
shell: bash | |
- name: build the docker image | |
run: docker build -t ${{env.DOCKER_USERNAME}}/${{env.IMAGE_NAME}} ./backend | |
# run: docker build -t ${{env.DOCKER_USERNAME}}/tiller:${{steps.generate-tag.outputs.TAG}} . | |
- name: push the image to docker hub | |
run: | | |
docker push ${{env.DOCKER_USERNAME}}/${{env.IMAGE_NAME}} | |
echo "@${{github.repository_owner}}, image has been pushed to docker hub successfully" | |
echo "This is the github workspace: ${{github.workspace}}" |