Dev #105
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: | |
push: | |
# Publish `1.2.3` tags as releases. | |
tags: | |
- '*.*.*' | |
# Run tests for any PRs. | |
pull_request: | |
env: | |
IMAGE_NAME: all-about-vr | |
NODE_ENV: production | |
REACT_APP_APIURL: ${{ secrets.REACT_APP_APIURL }} | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: shimataro/ssh-key-action@v2.1.0 | |
with: | |
key: ${{ secrets.SSH_KEY }} | |
known_hosts: ${{ secrets.KNOWN_HOSTS }} | |
- uses: actions/checkout@v2 | |
- name: Run tests | |
run: | | |
if [ -f docker-compose.test.yml ]; then | |
DOCKER_BUILDKIT=1 docker-compose --file docker-compose.test.yml build | |
DOCKER_BUILDKIT=1 docker-compose --file docker-compose.test.yml run sut | |
else | |
DOCKER_BUILDKIT=1 docker build --file Dockerfile --ssh default=~/.ssh/id_rsa . | |
fi | |
push: | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
steps: | |
- uses: shimataro/ssh-key-action@v2.1.0 | |
with: | |
key: ${{ secrets.SSH_KEY }} | |
known_hosts: ${{ secrets.KNOWN_HOSTS }} | |
- uses: actions/checkout@v2 | |
- name: Build image | |
run: DOCKER_BUILDKIT=1 docker build --ssh default=~/.ssh/id_rsa . --file Dockerfile.prod | |
--build-arg REACT_APP_APIURL | |
--tag $IMAGE_NAME | |
- name: Log into GitHub Container Registry | |
run: echo "${{ secrets.CR_PAT }}" | docker login -u bleuh --password-stdin | |
- name: Push image to GitHub Container Registry | |
run: | | |
IMAGE_ID=${{ secrets.DOCKER_OWNER }}/$IMAGE_NAME | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# Strip git ref prefix from version | |
VERSION=${GITHUB_REF#refs/*/} | |
# Logs | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
# Tags | |
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | |
docker tag $IMAGE_NAME $IMAGE_ID:latest | |
# Push | |
docker push $IMAGE_ID |