Code Monkey home page Code Monkey logo

Comments (3)

 avatar commented on June 18, 2024

Similar question from me... I can't seem to pass a variable in to the tags field, e.g. ${GITHUB_REF##*/} should work but doesn't. I want tags to be dynamic from the repo,

from aws-ecr-action.

vinodjayachandran avatar vinodjayachandran commented on June 18, 2024

I figured out a way to do it.
Refer here - https://github.com/vinodjayachandran/spring-boot-docker/blob/master/.github/workflows/aws_ecr.yml

from aws-ecr-action.

dasheck0 avatar dasheck0 commented on June 18, 2024

I had the same issue. I wanted to add two tags. One with the branch as a denotation for the latest develop, master etc. And a concatenation of branch and package.json version, as it is a nodejs project. Here is my resulting (and working) yml file

name: Build and deploy docker image to ECR

on:
  push:
    branches: [master, develop]

jobs:
  build-and-push:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: get-npm-version
        uses: martinbeentjes/npm-get-version-action@master
        id: package-version

      - name: Extract branch name
        shell: bash
        run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
        id: branch

      - name: Build and push image
        uses: kciter/aws-ecr-action@v1
        with:
          access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          account_id: ${{ secrets.AWS_ACCOUNT_ID }}
          repo: ...
          region: eu-central-1
          tags: ${{ steps.branch.outputs.branch }}-${{ steps.package-version.outputs.current-version }},${{ steps.branch.outputs.branch }}

Hope this helps. Also the order of the tags was somewhat relevant. When I changed it I got a weird error where the action tried to take the tag as host for the docker url. Might be a bug. Take this and a clean NodeJS project as MWE for reproduction.

from aws-ecr-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.