|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '*' |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - '*' |
| 10 | + |
| 11 | +jobs: |
| 12 | + ShellCheck: |
| 13 | + name: Shellcheck |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v2 |
| 17 | + - name: ShellCheck Depends |
| 18 | + uses: ludeeus/action-shellcheck@master |
| 19 | + Docker: |
| 20 | + name: Docker |
| 21 | + runs-on: ubuntu-latest |
| 22 | + needs: ShellCheck |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + if: success() |
| 26 | + id: checkout |
| 27 | + uses: actions/checkout@v2 |
| 28 | + - name: Set up QEMU |
| 29 | + if: success() |
| 30 | + uses: docker/setup-qemu-action@v1 |
| 31 | + - name: Set up Docker Buildx |
| 32 | + if: success() |
| 33 | + id: buildx |
| 34 | + uses: docker/setup-buildx-action@v1 |
| 35 | + - name: Cache Docker layers |
| 36 | + uses: actions/cache@v2 |
| 37 | + with: |
| 38 | + path: /tmp/.buildx-cache |
| 39 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 40 | + restore-keys: | |
| 41 | + ${{ runner.os }}-buildx- |
| 42 | + - name: Prepare |
| 43 | + if: success() |
| 44 | + id: prepare |
| 45 | + run: | |
| 46 | + echo ::set-output name=docker_platforms::linux/amd64,linux/386 |
| 47 | + echo ::set-output name=docker_username::miigotu |
| 48 | + echo ::set-output name=github_image::ghcr.io/${GITHUB_REPOSITORY,,}/ps3dev |
| 49 | + VERSION_TAG=${GITHUB_REF#refs/*/} |
| 50 | + echo ::set-output name=version::${VERSION_TAG%/merge} |
| 51 | +# - name: Login to DockerHub |
| 52 | +# if: success() |
| 53 | +# id: login_docker |
| 54 | +# uses: docker/login-action@v1 |
| 55 | +# with: |
| 56 | +# username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 57 | +# password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 58 | + - name: Login to GitHub Container Registry |
| 59 | + if: success() |
| 60 | + id: login_github |
| 61 | + uses: docker/login-action@v1 |
| 62 | + with: |
| 63 | + registry: ghcr.io |
| 64 | + username: ${{ steps.prepare.outputs.docker_username }} |
| 65 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + - name: Build and push (master) |
| 67 | + if: success() && steps.prepare.outputs.version == 'master' && github.event_name != 'pull_request' |
| 68 | + id: build_push_master |
| 69 | + uses: docker/build-push-action@v2 |
| 70 | + with: |
| 71 | + context: . |
| 72 | + platforms: ${{ steps.prepare.outputs.docker_platforms }} |
| 73 | + push: true |
| 74 | + tags: | |
| 75 | + ${{ steps.prepare.outputs.github_image }}:master |
| 76 | + ${{ steps.prepare.outputs.github_image }}:latest |
| 77 | + - name: Build and push (development) |
| 78 | + if: success() && steps.prepare.outputs.version != 'master' |
| 79 | + id: build_push_development |
| 80 | + uses: docker/build-push-action@v2 |
| 81 | + with: |
| 82 | + context: . |
| 83 | + platforms: ${{ steps.prepare.outputs.docker_platforms }} |
| 84 | + push: true |
| 85 | + tags: | |
| 86 | + ${{ steps.prepare.outputs.github_image }}:${{ steps.prepare.outputs.version }} |
| 87 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 88 | + cache-to: type=local,dest=/tmp/.buildx-cache-new |
| 89 | + - name: Move cache |
| 90 | + if: success() |
| 91 | + # Temp fix |
| 92 | + # https://github.com/docker/build-push-action/issues/252 |
| 93 | + # https://github.com/moby/buildkit/issues/1896 |
| 94 | + run: | |
| 95 | + rm -rf /tmp/.buildx-cache |
| 96 | + mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
0 commit comments