I'm trying to save the output of running sbt print version | tail -n 1 to an environment variable in a Github Actions workflow, and it doesn't seem to work.
This is what I think should work, but it's just an empty string, when I try to access the variable later on in the job:
echo "TAG_VERSION=$(sbt 'print version' | tail -n 1)" >> $GITHUB_ENV
It works great in my own shell, but not in Github Actions.
I'm using version 1.5.3for sbt.
This is the logs for the step that doesn't seem to work, test version step, it just seems to not load up correctly.:
Run echo "TAG_VERSION=$(sbt 'print version' | tail -n 1)" >> $GITHUB_ENV
echo "TAG_VERSION=$(sbt 'print version' | tail -n 1)" >> $GITHUB_ENV
shell: /usr/bin/bash -e {0}
env:
CI: true
JAVA_HOME: /home/runner/.jabba/jdk/adopt@1.8.0-292
Downloading sbt launcher for 1.5.3:
From https://repo1.maven.org/maven2/org/scala-sbt/sbt-launch/1.5.3/sbt-launch-1.5.3.jar
To /home/runner/.sbt/launchers/1.5.3/sbt-launch.jar
Downloading sbt launcher 1.5.3 md5 hash:
From https://repo1.maven.org/maven2/org/scala-sbt/sbt-launch/1.5.3/sbt-launch-1.5.3.jar.md5
To /home/runner/.sbt/launchers/1.5.3/sbt-launch.jar.md5
[info] [launcher] getting org.scala-sbt sbt 1.5.3 (this may take some time)...
[info] [launcher] getting Scala 2.12.14 (for sbt)...
This is the full workflow:
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v11
#- name: run tests
# run: |
# sbt test
- name: docker login
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
#- name: build image and publish
# run: sbt 'Docker / publish'
- name: test version
run: echo "TAG_VERSION=$(sbt 'print version' | tail -n 1)" >> $GITHUB_ENV
- name: print test version
run: echo ${{ env.TAG_VERSION }}
- name: get version
run: echo "TAG_VERSION=$(echo $(sbt -Dsbt.supershell=false 'print version' | tail -n 1))" >> $GITHUB_ENV
- name: checkout helm repo
uses: actions/checkout@v2
with:
repository: peterstorm/dialer-integration-argo
token: ${{ secrets.ACCESS_TOKEN }}
path: './dialer-integration-argo'
- name: change image tag in helm repo
uses: mikefarah/yq@master
with:
cmd: yq eval -i '.image.tag = "${{ env.TAG_VERSION }}"' './dialer-integration-argo/values.yaml'
- name: push helm repo changes
run: |
cd dialer-integration-argo &&
git config --global user.name 'Peter Storm' &&
git config --global user.email 'peter.storm@peterstorm.io' &&
git add . &&
git commit -m "commit from github actions" &&
git push origin master
Thank you!