Release 5.4.0 #83
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker | |
on: | |
release: | |
types: [published] | |
env: | |
DOCKER_FILE: Dockerfile | |
DOCKER_REGISTRY: ghcr.io | |
OWNER: pagopa | |
jobs: | |
docker_release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: node_version | |
id: node_version | |
run: | | |
echo "current folder: $(pwd)" | |
FROM_SOURCE=$(cat .node-version || cat .nvmrc) | |
ls .node-version && echo ".node-version found, value: '$(cat .node-version)'" || echo ".node-version not found" | |
ls .nvmrc && echo ".nvmrc found, value: '$(cat .nvmrc)'" || echo ".nvmrc not found" | |
echo "set FROM_SOURCE='$FROM_SOURCE'" | |
echo "::set-output name=NODE_VERSION::$FROM_SOURCE" | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '${{ steps.node_version.outputs.NODE_VERSION }}' | |
- name: node_setup | |
run: | | |
node -v | |
npm install -g yarn | |
yarn install --frozen-lockfile | |
- name: test | |
run: | | |
yarn generate | |
yarn test | |
- name: build | |
run: | | |
yarn predeploy | |
- name: docker_build | |
env: | |
NODE_VERSION: '${{ steps.node_version.outputs.NODE_VERSION }}' | |
run: | | |
GITHUB_REPO=$(echo "${{ github.repository }}" | tr '[A-Z]' '[a-z]') | |
docker build . --file $DOCKER_FILE --tag $GITHUB_REPO \ | |
--build-arg NODE_VERSION=$NODE_VERSION \ | |
--build-arg OWNER=$OWNER \ | |
--build-arg REPO=$GITHUB_REPO | |
- name: docker_login | |
run: | | |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login $DOCKER_REGISTRY -u ${{ github.actor }} --password-stdin | |
- name: docker_push | |
run: | | |
GITHUB_REPO=$(echo "${{ github.repository }}" | tr '[A-Z]' '[a-z]') | |
IMAGE_ID=$DOCKER_REGISTRY/$GITHUB_REPO | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Strip "v" prefix from tag name | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
# Use Docker `latest` tag convention | |
[ "$VERSION" == "master" ] && VERSION=latest | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
docker tag $GITHUB_REPO $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION |