In my Docker project's repo, I have a VERSION file that contains nothing more than the version number.
1.2.3 In Travis, I'm able to cat the file to an environment variable, and use that to tag my build before pushing to Docker Hub.
--- env: global: - USER=username - REPO=my_great_project - VERSION=$(cat VERSION) What is the equivalent of that in GitHub Actions? I tried this, but it's not working.
name: Test on: ... ... env: USER: username REPO: my_great_project jobs: build_ubuntu: name: Build Ubuntu runs-on: ubuntu-latest env: BASE: ubuntu steps: - name: Check out the codebase uses: actions/checkout@v2 - name: Build the image run: | VERSION=$(cat VERSION) docker build --file ${BASE}/Dockerfile --tag ${USER}/${REPO}:${VERSION} . build_alpine: name: Build Alpine runs-on: ubuntu-latest env: BASE: alpine ... ... ... I've also tried this, which doesn't work.
- name: Build the image run: | echo "VERSION=$(cat ./VERSION)" >> $GITHUB_ENV docker build --file ${BASE}/Dockerfile --tag ${USER}/${REPO}:${VERSION} .
VERSIONin the environment, or do you just need it as the value of theVERSIONvariable in thedocker buildcommand?docker build,docker tag, anddocker pushVERSION=$(< VERSION)and then just use$VERSIONin the samerunstep. What you did in your first attempt, basically. How is that not working?VERSIONin the environment. I'm trying to use it in multiple steps, and don't want to set it every time. Is there a way to add it for all steps?