Skip to content

Create main.yml

Create main.yml #1

Workflow file for this run

name: Docker Hub CI
on:
  push:
    branches: ["master"]
  pull_request:
    branches: ["master"]
jobs:
  build_and_publish:
    runs-on: ubuntu-latest
    env:
      REPO_NAME: ${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Set ENV variables
        run: |
          echo "REPO_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV

Check failure on line 22 in .github/workflows/main.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/main.yml

Invalid workflow file

You have an error in your yaml syntax on line 22
      - name: Build the Docker image
        run: docker build . --file Dockerfile --tag $REPO_NAME
      - name: Login to Docker Hub
        run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "dhohirp" --password-stdin
      - name: Push Docker image to Docker Hub
        run: |
          docker tag $REPO_NAME "dhohirp/$REPO_NAME"
          docker push "dhohirp/$REPO_NAME"