diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..eba392f --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,27 @@ +name: Docker Image CI + +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: 'Create env file' + run: echo "${{ secrets.TWITTER.ENV.DEVELOPMENT }}" >> .env.development + - name: Build the Docker image + run: | + IMAGE_TAG=hmt1/twitter:$(date +%s) + docker build . --file Dockerfile.dev --tag $IMAGE_TAG + echo "::set-output name=image_tag::$IMAGE_TAG" + + - name: Login to Docker Hub + run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Push Image to Docker Hub + run: docker push ${{ steps.build.outputs.image_tag }}