Merge pull request #1469 from plus3it/dependabot/docker/mikefarah/yq-… #588
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: Build, test, and publish container image | |
| on: | |
| # Run pull requests against the default branch | |
| pull_request: | |
| branches: [master] | |
| # Run on push to default branch | |
| push: | |
| branches: [master] | |
| # Run when a release is created | |
| release: | |
| types: [released] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| steps: | |
| - name: Clone this git repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| - name: Docker meta | |
| if: github.event_name != 'pull_request' | |
| id: meta | |
| uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf | |
| with: | |
| # list of Docker images to use as base name for tags | |
| images: | | |
| plus3it/tardigrade-ci | |
| ghcr.io/plus3it/tardigrade-ci | |
| flavor: | | |
| latest=false | |
| # generate Docker tags based on the following events/attributes | |
| tags: | | |
| # set latest tag for default branch | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| # set version tags for releases | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/0.') }} | |
| - name: Login to Docker Hub | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Login to GitHub Container Registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd | |
| - name: Build and export | |
| uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f | |
| with: | |
| context: . | |
| load: true | |
| tags: plus3it/tardigrade-ci:test | |
| secrets: | | |
| "GITHUB_ACCESS_TOKEN=${{ secrets.GITHUB_TOKEN }}" | |
| - name: Run docker lint | |
| if: github.event_name == 'pull_request' | |
| env: | |
| IMAGE_NAME: plus3it/tardigrade-ci:test | |
| GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: make docker/run target="lint" | |
| - name: Run bats tests | |
| if: github.event_name == 'pull_request' | |
| run: docker run --rm -e "GITHUB_ACCESS_TOKEN=${{ secrets.GITHUB_TOKEN }}" plus3it/tardigrade-ci:test bats/test | |
| - name: Push to registries | |
| if: github.event_name != 'pull_request' | |
| uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f | |
| with: | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| secrets: | | |
| "GITHUB_ACCESS_TOKEN=${{ secrets.GH_READONLY_TOKEN }}" |