|
| 1 | +name: Build Multi Stage Docker Image |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches-ignore: |
| 5 | + - 'dependabot/**' |
| 6 | + schedule: |
| 7 | + - cron: '0 5 * * *' |
| 8 | + |
| 9 | +jobs: |
| 10 | + GHRC: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Checkout |
| 14 | + |
| 15 | + |
| 16 | + - uses: FranzDiebold/[email protected] |
| 17 | + - name: Print environment variables |
| 18 | + run: | |
| 19 | + echo "CI_REPOSITORY_NAME=$CI_REPOSITORY_NAME" |
| 20 | +
|
| 21 | + - name: Prepare GHRC.io |
| 22 | + id: prep |
| 23 | + run: | |
| 24 | + REPO=$CI_REPOSITORY_NAME |
| 25 | + DOCKER_IMAGE=${{ github.repository_owner }}/${REPO} |
| 26 | + if [ "$CI_REF_NAME" == "master" ];then VERSION=latest;fi |
| 27 | + if [ "$CI_REF_NAME" == "dev" ];then VERSION=mightly;fi |
| 28 | + if [ "$CI_REF_NAME" == "dockserver" ];then VERSION=dockserver;fi |
| 29 | + TAGS="${DOCKER_IMAGE}:${VERSION}" |
| 30 | + echo ::set-output name=tags::${TAGS} |
| 31 | + echo ::set-output name=title::${GITHUB_REPOSITORY} |
| 32 | + echo ::set-output name=version::${VERSION} |
| 33 | + echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| 34 | +
|
| 35 | + - name: Set up QEMU |
| 36 | + uses: docker/setup-qemu-action@v1 |
| 37 | + with: |
| 38 | + platforms: linux/amd64,linux/armhf,linux/arm64 |
| 39 | + |
| 40 | + - name: Set up Docker Buildx |
| 41 | + id: buildx |
| 42 | + |
| 43 | + |
| 44 | + - name: Cache Docker layers |
| 45 | + |
| 46 | + with: |
| 47 | + path: /tmp/.buildx-cache |
| 48 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 49 | + restore-keys: | |
| 50 | + ${{ runner.os }}-buildx- |
| 51 | +
|
| 52 | + - name: Login to GitHub Container Registry |
| 53 | + if: github.event_name != 'pull_request' |
| 54 | + |
| 55 | + with: |
| 56 | + registry: ghcr.io |
| 57 | + username: ${{ github.repository_owner }} |
| 58 | + password: ${{ secrets.CR_PAT }} |
| 59 | + |
| 60 | + - name: Build and push GHRC.io |
| 61 | + id: docker_build |
| 62 | + |
| 63 | + with: |
| 64 | + builder: ${{ steps.buildx.outputs.name }} |
| 65 | + context: . |
| 66 | + file: ./Dockerfile |
| 67 | + platforms: linux/amd64,linux/armhf,linux/arm64 |
| 68 | + push: ${{ github.event_name != 'pull_request' }} |
| 69 | + tags: ghcr.io/${{ steps.prep.outputs.tags }} |
| 70 | + labels: | |
| 71 | + org.opencontainers.image.title=${{ steps.prep.outputs.title }} |
| 72 | + org.opencontainers.image.version=${{ steps.prep.outputs.version }} |
| 73 | + org.opencontainers.image.created=${{ steps.prep.outputs.created }} |
| 74 | +
|
| 75 | + - name: Image digest |
| 76 | + run: echo ${{ steps.docker_build.outputs.digest }} |
0 commit comments