style: changes repo location and adds docs #8
This file contains hidden or 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: Place - (CI/CD) | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| push: | |
| branches: [ main ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Test | |
| uses: docker/build-push-action@v2 | |
| with: | |
| file: .docker/Dockerfile.test | |
| network: host | |
| push: | |
| if: github.event_name != 'pull_request' | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Prepare | |
| id: prep | |
| run: | | |
| GIT_HASH=$(git rev-parse --short "$GITHUB_SHA") | |
| DOCKER_IMAGE=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} | |
| TAGS="${DOCKER_IMAGE}:${GIT_HASH},${DOCKER_IMAGE}:latest" | |
| echo ::set-output name=tags::${TAGS} | |
| - name: Set up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v1 | |
| - name: Cache Docker layers | |
| uses: actions/cache@v2 | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: ${{ runner.os }}-buildx-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-buildx- | |
| - name: Login to ghcr | |
| uses: docker/login-action@v1 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| id: docker_build | |
| uses: docker/build-push-action@v2 | |
| with: | |
| builder: ${{ steps.buildx.outputs.name }} | |
| file: .docker/Dockerfile.prod | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.prep.outputs.tags }} | |
| target: runner | |
| cache-from: type=local,src=/tmp/.buildx-cache | |
| cache-to: type=local,dest=/tmp/.buildx-cache | |
| - name: Image digest | |
| run: echo ${{ steps.docker_build.outputs.digest }} |