Friday, February 3, 2023
HomeC#GitHub Actions For Publishing ASP.NET Docker Picture To The Registry

GitHub Actions For Publishing ASP.NET Docker Picture To The Registry

I’m an enormous fan of Docker Pictures. I often host my web sites inside a container and use Docker Hub to host my photos.

Each time I need to do a launch, I manually push my picture to the Docker Hub. This takes lots of time as a result of my purposes are fairly large. So, I’m looking for an answer to automate this step. The GitHub Actions have been my most suitable option as a result of I already hosted my supply code there.

GitHub actions will let you automate workflows that indicate constructing, working automated checks, or deploying.

You write a configuration file that specifies the workflow steps; then, a GitHub job will run them. Each account has 2000 minutes of execution. That is sufficient for nearly everybody.

Configure GitHub Workflow for ASP.NET software

  1. First, it’s essential to create a GitHub repository and push your code there. Your venture have to be already configured to work with Docker, so a Dockerfile is required. In the event you don’t have a Dockerfile, right-click on the venture and select Add > Docker help.
  2. Then go to the settings tab of the GitHub repository, Secrets and techniques, and choose Actions.
  3. Create the next data with the corresponding username and password of your Docker account:
    • DOCKER_PASSWORDGitHub Secrets
  4. Go to the Repository, and select the Actions tab. Choose to create a brand new workflow. Then you will note a few recipes that may be your place to begin. We is not going to select any of them, however there are good ones in the event you don’t know the best way to begin.GitHub Actions Recipes
  5.  Skip and choose arrange a workflow by your self.
  6. An editor will seem. Right here it’s essential to write the configuration file. The language used for configuration is YAML.
  7. Paste and alter this configuration the place it’s highlighted:
    title: Docker Picture CI
        branches: [ master ]
        branches: [ master ]
        runs-on: ubuntu-latest
        - makes use of: actions/[email protected]
        - title: docker login
            DOCKER_USER: ${{secrets and techniques.DOCKER_USER}}
            DOCKER_PASSWORD: ${{secrets and techniques.DOCKER_PASSWORD}}
          run: |
            docker login -u $DOCKER_USER -p $DOCKER_PASSWORD 
        - title: Arrange Docker Buildx
          makes use of: docker/[email protected]
        - title: Construct and push
          makes use of: docker/[email protected]
              context: .
              file: ./nameoftheproject/Dockerfile
              push: true
              tags: ${{ secrets and techniques.DOCKER_USER}}/nameoftheimage:newest
  8. Commit the file. Now the motion will begin. Go to the actions tab once more and test the standing of your workflow.

The configuration file specifies that the motion ought to run on push on the principle department. First, it logins on the Docker Hub utilizing your secrets and techniques, then builds the picture and pushes it. So, everytime you make a change on the principle department, the GitHub motion will run.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments