|
| 1 | +name: varken |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: '0 10 * * *' |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + - develop |
| 9 | + tags: |
| 10 | + - 'v*.*.*' |
| 11 | + paths: |
| 12 | + - '.github/workflows/docker.yaml' |
| 13 | + - 'varken/**' |
| 14 | + - 'Varken.py' |
| 15 | + - 'Dockerfile' |
| 16 | + pull_request: |
| 17 | + branches: |
| 18 | + - master |
| 19 | + - develop |
| 20 | + paths: |
| 21 | + - '.github/workflows/docker.yaml' |
| 22 | + - 'varken/**' |
| 23 | + - 'Varken.py' |
| 24 | + - 'Dockerfile' |
| 25 | + workflow_dispatch: |
| 26 | + inputs: |
| 27 | + tag: |
| 28 | + description: 'Use this tag instead of most recent' |
| 29 | + required: false |
| 30 | + ignore-existing-tag: |
| 31 | + description: 'Ignore existing tag if "true"' |
| 32 | + required: false |
| 33 | +env: |
| 34 | + IMAGES: boerderij/varken |
| 35 | + PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7" |
| 36 | +jobs: |
| 37 | + lint-and-test: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + - name: Checkout |
| 41 | + uses: actions/checkout@v2 |
| 42 | + - name: Setup Python |
| 43 | + uses: actions/setup-python@v2 |
| 44 | + with: |
| 45 | + python-version: '3.x' |
| 46 | + - name: Lint |
| 47 | + run: pip install flake8 && flake8 --max-line-length 120 Varken.py varken/*.py |
| 48 | + build: |
| 49 | + runs-on: ubuntu-latest |
| 50 | + needs: lint-and-test |
| 51 | + steps: |
| 52 | + - name: Checkout |
| 53 | + uses: actions/checkout@v2 |
| 54 | + - name: Prepare |
| 55 | + id: prep |
| 56 | + run: | |
| 57 | + VERSION=edge |
| 58 | + if [[ $GITHUB_REF == refs/tags/* ]]; then |
| 59 | + VERSION=${GITHUB_REF#refs/tags/v} |
| 60 | + fi |
| 61 | + if [ "${{ github.event_name }}" = "schedule" ]; then |
| 62 | + VERSION=nightly |
| 63 | + fi |
| 64 | + if [[ ${GITHUB_REF##*/} == "develop" ]]; then |
| 65 | + VERSION=develop |
| 66 | + fi |
| 67 | + TAGS="${VERSION}" |
| 68 | + if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then |
| 69 | + TAGS="$TAGS,latest" |
| 70 | + fi |
| 71 | + echo ::set-output name=version::${VERSION} |
| 72 | + echo ::set-output name=tags::${TAGS} |
| 73 | + echo ::set-output name=branch::${GITHUB_REF##*/} |
| 74 | + echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| 75 | + echo ::set-output name=vcs_ref::${GITHUB_SHA::8} |
| 76 | + - uses: ./.github/actions/docker-target-image-list-action |
| 77 | + name: Generate Target Images |
| 78 | + id: gen-tags |
| 79 | + with: |
| 80 | + images: ${{ env.IMAGES }} |
| 81 | + tags: ${{ steps.prep.outputs.tags }} |
| 82 | + - name: Set up QEMU |
| 83 | + uses: docker/setup-qemu-action@v1 |
| 84 | + with: |
| 85 | + platforms: ${{ env.PLATFORMS }} |
| 86 | + - name: Set up Docker Buildx |
| 87 | + uses: docker/setup-buildx-action@v1 |
| 88 | + with: |
| 89 | + install: true |
| 90 | + version: latest |
| 91 | + driver-opts: image=moby/buildkit:master |
| 92 | + - name: Docker Multi Login |
| 93 | + uses: ./.github/actions/docker-multi-login-action |
| 94 | + env: |
| 95 | + secrets: ${{ toJSON(secrets) }} |
| 96 | + - name: Build and Push |
| 97 | + uses: docker/build-push-action@v2 |
| 98 | + with: |
| 99 | + context: . |
| 100 | + file: ./Dockerfile |
| 101 | + platforms: ${{ env.PLATFORMS }} |
| 102 | + pull: true |
| 103 | + push: ${{ github.event_name != 'pull_request' }} |
| 104 | + tags: ${{ steps.gen-tags.outputs.fully-qualified-target-images }} |
| 105 | + build-args: | |
| 106 | + VERSION=${{ steps.prep.outputs.version }} |
| 107 | + BRANCH=${{ steps.prep.outputs.branch }} |
| 108 | + BUILD_DATE=${{ steps.prep.outputs.build_date }} |
| 109 | + VCS_REF=${{ steps.prep.outputs.vcs_ref }} |
| 110 | + - name: Inspect |
| 111 | + if: ${{ github.event_name != 'pull_request' }} |
| 112 | + run: | |
| 113 | + IFS=',' read -r -a images <<< "${{ steps.gen-tags.outputs.fully-qualified-target-images }}" |
| 114 | + for image in "${images[@]}"; do |
| 115 | + docker buildx imagetools inspect ${image} |
| 116 | + done |
0 commit comments