|
| 1 | +name: "Docker: build and publish" |
| 2 | + |
| 3 | +# How to setup: https://event-driven.io/en/how_to_buid_and_push_docker_image_with_github_actions/ |
| 4 | +# How to run: https://aschmelyun.com/blog/using-docker-run-inside-of-github-actions/ |
| 5 | + |
| 6 | +on: |
| 7 | + # run it on push to the default repository branch |
| 8 | + push: |
| 9 | + # branches: [master] |
| 10 | + # run it during pull request |
| 11 | + # pull_request: |
| 12 | + |
| 13 | +jobs: |
| 14 | + # define job to build and publish docker image |
| 15 | + build-and-push-docker-image: |
| 16 | + name: Build Docker image and push to repositories |
| 17 | + # run only when code is compiling and tests are passing |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + # steps to perform in job |
| 21 | + steps: |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@v3 |
| 24 | + |
| 25 | + - name: Set up QEMU |
| 26 | + uses: docker/setup-qemu-action@v2 |
| 27 | + |
| 28 | + # setup Docker build action |
| 29 | + - name: Set up Docker Buildx |
| 30 | + id: buildx |
| 31 | + uses: docker/setup-buildx-action@v2 |
| 32 | + |
| 33 | + - name: Login to DockerHub |
| 34 | + uses: docker/login-action@v2 |
| 35 | + with: |
| 36 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 37 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 38 | + |
| 39 | + - name: Login to Github Packages |
| 40 | + uses: docker/login-action@v2 |
| 41 | + with: |
| 42 | + registry: ghcr.io |
| 43 | + username: ${{ github.actor }} |
| 44 | + password: ${{ secrets.GHCR_IO_TOKEN }} |
| 45 | + |
| 46 | + - name: "no_qr_reader: Build image and push to Docker Hub and GitHub Container Registry" |
| 47 | + uses: docker/build-push-action@v2 |
| 48 | + with: |
| 49 | + # relative path to the place where source code with Dockerfile is located |
| 50 | + platforms: linux/amd64,linux/arm64 |
| 51 | + context: . |
| 52 | + file: Dockerfile_no_qr_reader |
| 53 | + # Note: tags has to be all lower-case |
| 54 | + tags: | |
| 55 | + scit0/extract_otp_secret_keys_no_qr_reader:latest |
| 56 | + ghcr.io/scito/extract_otp_secret_keys_no_qr_reader:latest |
| 57 | + # build on feature branches, push only on master branch |
| 58 | + # TODO push: ${{ github.ref == 'refs/heads/master' }} |
| 59 | + push: true |
| 60 | + |
| 61 | + - name: "qr_reader: Build image and push to Docker Hub and GitHub Container Registry" |
| 62 | + uses: docker/build-push-action@v2 |
| 63 | + with: |
| 64 | + platforms: linux/amd64,linux/arm64 |
| 65 | + # relative path to the place where source code with Dockerfile is located |
| 66 | + context: . |
| 67 | + # Note: tags has to be all lower-case |
| 68 | + tags: | |
| 69 | + scit0/extract_otp_secret_keys:latest |
| 70 | + ghcr.io/scito/extract_otp_secret_keys:latest |
| 71 | + # build on feature branches, push only on master branch |
| 72 | + # TODO push: ${{ github.ref == 'refs/heads/master' }} |
| 73 | + push: true |
| 74 | + |
| 75 | + - name: Image digest |
| 76 | + run: echo ${{ steps.docker_build.outputs.digest }} |
0 commit comments