Skip to content

Testing more advanced Github Action #2

Testing more advanced Github Action

Testing more advanced Github Action #2

Workflow file for this run

name: Docker Image CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
REPO_USERNAME: ${{ github.repository.owner }}
IMAGE_NAME: fastapi-data-collector
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Login to Github Repo
run: |
export CR_PAT=${{ secrets.GITHUB_TOKEN }}
echo $CR_PAT | docker login ghcr.io -u $REPO_USERNAME --password-stdin
- name: Build the Docker image
run: docker build . --file Dockerfile --tag ghcr.io/$REPO_USERNAME/$IMAGE_NAME:$GITHUB_SHA --tag ghcr.io/$REPO_USERNAME/$IMAGE_NAME:latest
- name: Push to Github Repo
run: |
docker push ghcr.io/$REPO_USERNAME/$IMAGE_NAME:$GITHUB_SHA
docker push ghcr.io/$REPO_USERNAME/$IMAGE_NAME:latest