Giter VIP home page Giter VIP logo

Comments (8)

ibnesayeed avatar ibnesayeed commented on May 20, 2024 5

I usually publish bleeding-edge changes of the master branch with master tag and reserve the latest for when the repo is tagged. This way, people who pull my images without explicit tags can always get something that I explicitly released.

  • on push to a branch
    • build image with the branch name as the image tag
  • on release/repo tag
    • build image with the tag ref as the image tag
    • build image with latest tag

from build-push-action.

felipecrs avatar felipecrs commented on May 20, 2024

I think this also fixes #40, since we'd be able to define custom conditions for pushing latest, such as the branch name.

Something like:

tag_with_latest: ${{ github.ref == 'refs/heads/develop' && github.event_name == 'push' }}

from build-push-action.

felipecrs avatar felipecrs commented on May 20, 2024

@ibnesayeed yeah, this is also my intended behavior that will be possible with this feature suggestion.

# Use the following if you just push as latest when push git tags
tag_with_latest: ${{ startsWith(github.ref, 'refs/tags/') }} 

from build-push-action.

felipecrs avatar felipecrs commented on May 20, 2024

Ok, I wrongly thought there was a boolean input called latest already. I rewrote the Issue/Feature Request.

from build-push-action.

hholst80 avatar hholst80 commented on May 20, 2024

Great workflow suggestion. However isn't this solvable outside this extension? Simply don't run the action unless there is a tag set.

from build-push-action.

felipecrs avatar felipecrs commented on May 20, 2024

Right, but what to do if we want to run the action in both cases, but only push as latest when is a tag? Without this feature, we would at least have to create 2 (and mainly duplicated) different jobs.

from build-push-action.

sagikazarmark avatar sagikazarmark commented on May 20, 2024

I like the idea, personally I was surprised to see that master will also be tagged as latest. As a workaround I have two separate docker steps.

One for the regular CI jobs:

on:
  push:
    branches:
      - master
  pull_request:

#...
      - name: Determine tag
        uses: haya14busa/action-cond@v1
        id: imagetag
        with:
          cond: ${{ github.event_name == 'pull_request' }}
          if_true: ${{ github.sha }}
          if_false: "master"

      - name: Build
        uses: docker/build-push-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
          repository: sagikazarmark/myrepo
          tags: ${{ steps.imagetag.outputs.value }}
          add_git_labels: true
          push: ${{ github.event_name == 'push' }}

And one for releases:

on:
  push:
    tags:
      - "v[0-9]+.[0-9]+.[0-9]+"

jobs:
  docker:
    name: Docker
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Build and push image
        uses: docker/build-push-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
          repository: sagikazarmark/myrepo
          tags: latest
          tag_with_ref: true
          add_git_labels: true

from build-push-action.

crazy-max avatar crazy-max commented on May 20, 2024

Solved by #119. See https://github.com/docker/build-push-action#complete-workflow

from build-push-action.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.