Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass timestamp for tags #6

Closed
vinodjayachandran opened this issue Apr 27, 2020 · 3 comments
Closed

How to pass timestamp for tags #6

vinodjayachandran opened this issue Apr 27, 2020 · 3 comments

Comments

@vinodjayachandran
Copy link

For Tags is it possible to pass a Unix expression to take the current time stamp. Example below

tags: date +%F-%I-%M``

@ghost
Copy link

ghost commented May 17, 2020

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,

@vinodjayachandran
Copy link
Author

@dasheck0
Copy link

dasheck0 commented Aug 6, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants