Move env declaration to jobs.docker

This commit is contained in:
Fahmi Akbar Wildana 2019-11-11 07:51:41 +07:00
parent 3e14de158b
commit 7cf3c6eb95
No known key found for this signature in database
GPG Key ID: 86D1FDF35E9D3807
2 changed files with 16 additions and 20 deletions

View File

@ -35,6 +35,10 @@ jobs:
name: Build and publish docker images name: Build and publish docker images
needs: compile needs: compile
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
DOCKER_REGISTRY: quay.io/nushell
DOCKER_PASSWORD: ${{ secrets.DOCKER_REGISTRY }}
DOCKER_USER: nushell+action # TBD
strategy: strategy:
matrix: matrix:
tag: tag:
@ -63,19 +67,16 @@ jobs:
with: { name: '${{ matrix.arch }}', path: target/release } with: { name: '${{ matrix.arch }}', path: target/release }
- name: Build and publish exact version - name: Build and publish exact version
run: |- run: |-
REGISTRY=${REGISTRY,,}; export TAG=${GITHUB_REF##*/}-${{ matrix.tag }} export DOCKER_TAG=${GITHUB_REF##*/}-${{ matrix.tag }}
export NU_BINS=target/release/$( [ ${{ matrix.plugin }} = true ] && echo nu* || echo nu ) export NU_BINS=target/release/$( [ ${{ matrix.plugin }} = true ] && echo nu* || echo nu )
export PATCH=$([ ${{ matrix.use-patch }} = true ] && echo .${{ matrix.tag }} || echo '') export PATCH=$([ ${{ matrix.use-patch }} = true ] && echo .${{ matrix.tag }} || echo '')
chmod +x $NU_BINS chmod +x $NU_BINS
echo ${{ secrets.DOCKER_REGISTRY }} | docker login ${REGISTRY%/*} -u ${USER,,} --password-stdin echo ${DOCKER_PASSWORD} | docker login ${DOCKER_REGISTRY} -u ${DOCKER_USER} --password-stdin
docker-compose --file docker/docker-compose.package.yml build docker-compose --file docker/docker-compose.package.yml build
docker-compose --file docker/docker-compose.package.yml push # exact version docker-compose --file docker/docker-compose.package.yml push # exact version
env: env:
BASE_IMAGE: ${{ matrix.base-image }} BASE_IMAGE: ${{ matrix.base-image }}
# REGISTRY: docker.pkg.github.com/${{ github.repository }} #TODO: waiting support for GITHUB_TOKEN for docker.pkg.github.com
USER: ${{ github.actor }}+action
REGISTRY: quay.io/${{ github.actor }}
#region semantics tagging #region semantics tagging
- name: Retag and push with suffixed version - name: Retag and push with suffixed version
@ -90,16 +91,14 @@ jobs:
tags=( ${latest_version} ${latest_feature} ${latest_patch} ${exact_version} ) tags=( ${latest_version} ${latest_feature} ${latest_patch} ${exact_version} )
for tag in ${tags[@]}; do for tag in ${tags[@]}; do
docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${tag} docker tag ${DOCKER_REGISTRY}/nu:${VERSION}-${{ matrix.tag }} ${DOCKER_REGISTRY}/nu:${tag}
docker push ${REGISTRY,,}/nu:${tag} docker push ${DOCKER_REGISTRY}/nu:${tag}
done done
# latest version # latest version
docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${{ matrix.tag }} docker tag ${DOCKER_REGISTRY}/nu:${VERSION}-${{ matrix.tag }} ${DOCKER_REGISTRY}/nu:${{ matrix.tag }}
docker push ${REGISTRY,,}/nu:${{ matrix.tag }} docker push ${DOCKER_REGISTRY}/nu:${{ matrix.tag }}
env:
# REGISTRY: 'docker.pkg.github.com/${{ github.repository }}' #TODO: waiting support for GITHUB_TOKEN for docker.pkg.github.com
REGISTRY: quay.io/${{ github.actor }}
- name: Retag and push debian as latest - name: Retag and push debian as latest
if: matrix.tag == 'debian' if: matrix.tag == 'debian'
run: |- run: |-
@ -109,14 +108,11 @@ jobs:
tags=( ${VERSION%%.*} ${VERSION%.*} ${VERSION} ) tags=( ${VERSION%%.*} ${VERSION%.*} ${VERSION} )
for tag in ${tags[@]}; do for tag in ${tags[@]}; do
docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${tag} docker tag ${DOCKER_REGISTRY}/nu:${VERSION}-${{ matrix.tag }} ${DOCKER_REGISTRY}/nu:${tag}
docker push ${REGISTRY,,}/nu:${tag} docker push ${DOCKER_REGISTRY}/nu:${tag}
done done
# latest version # latest version
docker tag ${REGISTRY,,}/nu:${{ matrix.tag }} ${REGISTRY,,}/nu:latest docker tag ${DOCKER_REGISTRY}/nu:${{ matrix.tag }} ${DOCKER_REGISTRY}/nu:latest
docker push ${REGISTRY,,}/nu:latest docker push ${DOCKER_REGISTRY}/nu:latest
env:
# REGISTRY: 'docker.pkg.github.com/${{ github.repository }}' #TODO: waiting support for GITHUB_TOKEN for docker.pkg.github.com
REGISTRY: quay.io/${{ github.actor }}
#endregion semantics tagging #endregion semantics tagging

View File

@ -2,7 +2,7 @@ version: '3'
services: services:
nushell: nushell:
image: ${REGISTRY}/nu:${TAG} image: ${DOCKER_REGISTRY}/nu:${DOCKER_TAG}
build: build:
context: .. context: ..
dockerfile: docker/Package${PATCH}.Dockerfile dockerfile: docker/Package${PATCH}.Dockerfile