|
| 1 | +name: tinyproxy |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 10 * * *" |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - "**" |
| 9 | + tags: |
| 10 | + - "v*.*.*" |
| 11 | + pull_request: |
| 12 | + branches: |
| 13 | + - "main" |
| 14 | + |
| 15 | +jobs: |
| 16 | + tinyproxy: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Set variables useful for later |
| 20 | + id: useful_vars |
| 21 | + run: |- |
| 22 | + echo "::set-output name=timestamp::$(date +%s)" |
| 23 | + echo "::set-output name=short_sha::${GITHUB_SHA::8}" |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v3 |
| 26 | + - name: Docker meta |
| 27 | + id: docker_meta |
| 28 | + uses: docker/metadata-action@v4 |
| 29 | + with: |
| 30 | + images: ghcr.io/${{ github.repository }}/tinyproxy |
| 31 | + tags: | |
| 32 | + type=schedule |
| 33 | + type=ref,event=branch |
| 34 | + type=ref,event=pr |
| 35 | + type=semver,pattern={{version}} |
| 36 | + type=semver,pattern={{major}}.{{minor}} |
| 37 | + type=semver,pattern={{major}} |
| 38 | + type=sha,prefix=,format=long,event=tag |
| 39 | + type=sha |
| 40 | + type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} |
| 41 | + type=raw,value=${{ github.ref_name }}-${{ steps.useful_vars.outputs.short_sha }}-${{ steps.useful_vars.outputs.timestamp }},enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} |
| 42 | + - name: Set up QEMU |
| 43 | + uses: docker/setup-qemu-action@v2 |
| 44 | + - name: Set up Docker Buildx |
| 45 | + uses: docker/setup-buildx-action@v2 |
| 46 | + - name: Login to GHCR |
| 47 | + if: github.event_name != 'pull_request' |
| 48 | + uses: docker/login-action@v2 |
| 49 | + with: |
| 50 | + registry: ghcr.io |
| 51 | + username: ${{ github.repository_owner }} |
| 52 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + - name: Cache Docker layers |
| 54 | + uses: actions/cache@v3 |
| 55 | + with: |
| 56 | + path: /tmp/.buildx-cache |
| 57 | + key: ${{ runner.os }}-tinyproxy-buildx-${{ github.sha }} |
| 58 | + restore-keys: | |
| 59 | + ${{ runner.os }}-tinyproxy-buildx- |
| 60 | + - name: Build and push |
| 61 | + uses: docker/build-push-action@v4 |
| 62 | + with: |
| 63 | + context: tinyproxy |
| 64 | + push: ${{ github.event_name != 'pull_request' }} |
| 65 | + tags: ${{ steps.docker_meta.outputs.tags }} |
| 66 | + labels: ${{ steps.docker_meta.outputs.labels }} |
| 67 | + platforms: linux/amd64,linux/arm64 |
| 68 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 69 | + cache-to: type=local,dest=/tmp/.buildx-cache,mode=max |
0 commit comments