Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Ground Controller Lvl 2
Message 1 of 4

Add build version to docker image deployed to AWS

Hi All,

I am trying to add build version to docker image being deployed to AWS ECR.

My yml looks as below  :

*******************************
on:
push:
branches:
- master
env:
- BUILD_VERSION=latest

name: Deploy to Amazon ECS

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest

 

************************


Tried modifying that to

*****************

env:
- BUILD_VERSION=latest

*****************

### ERRORED 05:49:08Z

- Your workflow file was invalid: The pipeline is not valid. .github/workflows/aws.yml (Line: 32, Col: 3): A sequence was not expected

Still the same error !

Help in resolving the issue


Thanks,
Zaheer

3 Replies
GitHub Partner
Message 2 of 4

Re: Add build version to docker image deployed to AWS

The syntax you are using to define the environment variable is incorrect, the correct syntax should be:

env:

  BUILD_VERSION: latest

 

More details about the syntax, you can reference here: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-...

Ground Controller Lvl 2
Message 3 of 4

Re: Add build version to docker image deployed to AWS

I tried the same it gives error

 

### ERRORED 09:12:38Z

- Your workflow file was invalid: The pipeline is not valid. .github/workflows/aws.yml (Line: 65, Col: 21): Unrecognized named-value: 'BUILD_VERSION'. Located at position 1 within expression: BUILD_VERSION
GitHub Partner
Message 4 of 4

Re: Add build version to docker image deployed to AWS

According to the error message, you seem used an incorrect syntax to call the environment variable in the steps.

  • If call the environment variable in an if conditional, the syntax is:

    If: env.VARIABLE_NAME == ‘value’

    However this syntax is only available for step level to skip steps, not for job level. Currently I do not find any useable syntax on job level to use environment variable in if conditional .

  • If call the environment variable in command lines, the syntaxes are different with different shells.

example.PNG