diff options
| author | 2021-12-11 16:22:42 +0000 | |
|---|---|---|
| committer | 2021-12-11 16:25:45 +0000 | |
| commit | aa75ec9646bc0b1d4e603a730b465c88385f2079 (patch) | |
| tree | 5b821ba3912630db799107451c51fa038622ebc0 | |
| parent | Add Dockerfile for pg_cron psql:14-alpine (diff) | |
Add build workflow for push to ghcr
| -rw-r--r-- | .github/workflows/build.yml | 59 | 
1 files changed, 59 insertions, 0 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d71d520 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,59 @@ +name: Build + +on: +  push: +    branches: +      - main + +concurrency: +  group: ${{ github.workflow }}-${{ github.ref }} +  cancel-in-progress: true + +jobs: +  build: +    runs-on: ubuntu-latest + +    steps: +      # Create a commit SHA-based tag for the container repositories +      - name: Create SHA Container Tag +        id: sha_tag +        run: | +          tag=$(cut -c 1-7 <<< $GITHUB_SHA) +          echo "::set-output name=tag::$tag" + +      - name: Checkout code +        uses: actions/checkout@v2 + +      # The current version (v2) of Docker's build-push action uses +      # buildx, which comes with BuildKit features that help us speed +      # up our builds using additional cache features. Buildx also +      # has a lot of other features that are not as relevant to us. +      # +      # See https://github.com/docker/build-push-action +      - name: Set up Docker Buildx +        uses: docker/setup-buildx-action@v1 + +      - name: Login to Github Container Registry +        uses: docker/login-action@v1 +        with: +          registry: ghcr.io +          username: ${{ github.repository_owner }} +          password: ${{ secrets.GITHUB_TOKEN  }} + +      # Build and push the container to the GitHub Container +      # Repository. The container will be tagged as "latest" +      # and with the short SHA of the commit. +      - name: Build and push +        uses: docker/build-push-action@v2 +        with: +          context: . +          file: ./Dockerfile +          push: true +          cache-from: type=registry,ref=ghcr.io/chrislovering/psql_pg_cron:latest +          cache-to: type=inline +          tags: | +            ghcr.io/chrislovering/psql_pg_cron:latest +            ghcr.io/chrislovering/psql_pg_cron:14 +            ghcr.io/chrislovering/psql_pg_cron:${{ steps.sha_tag.outputs.tag }} +          build-args: | +            git_sha=${{ github.sha }}  |