Building and publishing images to Docker Registry

Instead of creating multiple actions to build, tag, login, and push to Docker Repository, you can use one action to achieve all at once. Let's perform the following steps:

  1. Sign in to your GitHub account.
  2. Select a repository where you have maintainer access. In our example, we are using the fork of the k8sdevopscookbook/python-flask-docker project.
  3. Click the Actionstab.
  4. From here, click on Add a new workflow.
  5. Create a dockerpush.yml file under the .github/workflows directory with the following content. Make sure to change MyDockerRepo/repository so that it uses the name of the image you would like to push:
name: Build and Push to DockerHub
on: [push]
jobs:
build: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@master with: name: MyDockerRepo/repository username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }}
  1. Click on the Settings tab and go to the Secrets menu.
  2. Create a DOCKER_USERNAME secret with the value equals to the username you used to log in to your Docker Registry.
  3. Create DOCKER_PASSWORD secrets with a value equals to the password you used to log in to your Docker Registry. After both secrets have been created, you should be able to see them in the Secrets menu, as shown in the following screenshot:

Environmental variables stored as secrets will be encrypted and are only available for selected actions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.204.0