diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 23652ca..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,327 +0,0 @@ -version: 2.1 - -orbs: - shellcheck: circleci/shellcheck@1.3.16 - docker: circleci/docker@1.0.1 - go: circleci/go@1.1.1 - -commands: - docker-build: - description: | - Build and optionally deploy a Docker images - parameters: - dockerfile: - default: Dockerfile - description: 'Name of dockerfile to use, defaults to Dockerfile' - type: string - extra_build_args: - default: '' - description: > - Extra flags to pass to docker build. For examples, see - https://docs.docker.com/engine/reference/commandline/build - type: string - registry: - default: docker.io - description: | - Comma separated list of registry to use, defaults to docker.io - type: string - image: - description: Name of image to build - type: string - tag: - default: $CIRCLE_SHA1 - description: 'Image tag, defaults to the value of $CIRCLE_SHA1' - type: string - path: - default: . - description: > - Path to the directory containing your Dockerfile and build context, - defaults to . (working directory) - type: string - cache_from: - default: '' - description: > - Comma-separated list of images, images will first be pulled, then passed - as the --cache-from build argument - https://docs.docker.com/engine/reference/commandline/build/ - type: string - no_output_timeout: - default: 10m - description: | - No output timeout for build step - type: string - steps: - - when: - condition: <> - steps: - - run: - name: Build image for <> - no_output_timeout: <> - command: > - echo "<>" | sed -n 1'p' | tr ',' '\n' | - while read image; do - echo "Pulling ${image}"; - docker pull ${image} || true - done - - docker_tag_args="" - - IFS="," read -ra DOCKER_REGISTRIES \<<< "<< parameters.registry >>" - - for registry in "${DOCKER_REGISTRIES[@]}"; do - IFS="," read -ra DOCKER_TAGS \<<< "<< parameters.tag >>" - - for tag in "${DOCKER_TAGS[@]}"; do - docker_tag_args="$docker_tag_args -t $registry/<>:${tag}" - done - done - - docker build - <<#parameters.extra_build_args>><><> - \ - --cache-from <> \ - -f <>/<> \ - $docker_tag_args \ - <> - - unless: - condition: <> - steps: - - run: - name: Building image for <> - no_output_timeout: <> - command: > - docker_tag_args="" - - IFS="," read -ra DOCKER_REGISTRIES \<<< "<< parameters.registry >>" - - for registry in "${DOCKER_REGISTRIES[@]}"; do - IFS="," read -ra DOCKER_TAGS \<<< "<< parameters.tag >>" - - for tag in "${DOCKER_TAGS[@]}"; do - docker_tag_args="$docker_tag_args -t $registry/<>:${tag}" - done - done - - docker build - <<#parameters.extra_build_args>><><> - \ - -f <>/<> \ - $docker_tag_args \ - <> - - docker-save: - description: | - Save one or more images to a tar archive - parameters: - registry: - default: docker.io - description: | - Comma separated list of registry to use, defaults to docker.io - type: string - image: - description: Name of image to build - type: string - tag: - default: $CIRCLE_SHA1 - description: 'Image tag, defaults to the value of $CIRCLE_SHA1' - type: string - steps: - - run: - name: Save image to tar archive - command: > - docker_images="" - - IFS="," read -ra DOCKER_REGISTRIES \<<< "<< parameters.registry >>" - - for registry in "${DOCKER_REGISTRIES[@]}"; do - IFS="," read -ra DOCKER_TAGS \<<< "<< parameters.tag >>" - - for tag in "${DOCKER_TAGS[@]}"; do - docker_images="$docker_images $registry/<>:${tag}" - done - done - - mkdir -p ~/docker/ - - docker save -o ~/docker/docker-images.tar $docker_images - - persist_to_workspace: - root: ~/ - paths: - - docker - - docker-load: - description: | - Load tar archive - steps: - - attach_workspace: - at: ~/ - - run: - name: Load images from tar archive - command: > - docker load -i ~/docker/docker-images.tar - - docker-publish: - description: | - Build and optionally deploy a Docker images - parameters: - pr: - default: '' - type: string - registry: - default: docker.io - description: | - Comma separated list of registry to use, defaults to docker.io - type: string - image: - description: Name of image to build - type: string - tag: - default: $CIRCLE_SHA1 - description: 'Image tag, defaults to the value of $CIRCLE_SHA1' - type: string - steps: - - unless: - condition: <> - steps: - - run: - name: Publish image for <> - command: > - IFS="," read -ra DOCKER_REGISTRIES \<<< "<< parameters.registry >>" - - for registry in "${DOCKER_REGISTRIES[@]}"; do - IFS="," read -ra DOCKER_TAGS \<<< "<< parameters.tag >>" - - for tag in "${DOCKER_TAGS[@]}"; do - docker push $registry/<< parameters.image>>:${tag} - done - done - -jobs: - build: - executor: docker/machine - steps: - - checkout - - docker-build: - registry: docker.io,quay.io - image: sameersbn/postgresql - tag: ${CIRCLE_TAG:-latest} - cache_from: docker.io/sameersbn/postgresql:latest - - docker-save: - registry: docker.io,quay.io - image: sameersbn/postgresql - tag: ${CIRCLE_TAG:-latest} - - test: - executor: docker/machine - steps: - - checkout - - docker-load - - run: - name: Update tag in docker-compose.yml - command: | - sed -i "s|image: sameersbn/postgresql:.*|image: sameersbn/postgresql:${CIRCLE_TAG:-latest}|" docker-compose.yml - - run: - name: Launch postgresql container - command: docker-compose up -d --quiet-pull - - run: - name: Wait for bootup - command: sleep 15 - - run: - name: Container info - command: docker ps - - run: - name: Test image - command: docker exec $(docker-compose ps -q PostgreSQL) pg_isready - - publish-dockerhub: - executor: docker/machine - steps: - - docker-load - - docker/check: - registry: docker.io - docker-username: DOCKER_LOGIN - docker-password: DOCKER_PASSWORD - - docker-publish: - registry: docker.io - image: sameersbn/postgresql - tag: ${CIRCLE_TAG:-latest} - - publish-quay: - executor: docker/machine - steps: - - docker-load - - docker/check: - registry: quay.io - docker-username: DOCKER_LOGIN - docker-password: DOCKER_PASSWORD - - docker-publish: - registry: quay.io - image: sameersbn/postgresql - tag: ${CIRCLE_TAG:-latest} - - release: - executor: - name: go/default - tag: '1.14' - steps: - - checkout - - run: - name: Installing github-release tool - command: go get github.com/meterup/github-release - - run: - name: Creating github release - command: | - PRE_RELEASE=${CIRCLE_TAG/${CIRCLE_TAG%-rc[0-9]*}/} - github-release delete -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -t ${CIRCLE_TAG} 2>/dev/null ||: - ./scripts/release-notes.sh ${CIRCLE_TAG} | github-release release ${PRE_RELEASE:+-p} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -t ${CIRCLE_TAG} -d - - for f in $(find /tmp/dist -type f); do github-release upload -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -t ${CIRCLE_TAG} -n $(basename ${f}) -f ${f} ; done - -workflows: - build-test-and-release: - jobs: - - shellcheck/check: - name: shellcheck - ignore: SC2086,SC2181,SC2124 - filters: - tags: - only: /^([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/ - - build: - requires: - - shellcheck - filters: - tags: - only: /^([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/ - - test: - requires: - - build - filters: - tags: - only: /^([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/ - - publish-dockerhub: - context: dockerhub - requires: - - test - filters: - branches: - only: master - tags: - only: /^([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/ - - publish-quay: - context: quay - requires: - - test - filters: - tags: - only: /^([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/ - branches: - only: master - - release: - context: github - requires: - - publish-dockerhub - - publish-quay - filters: - tags: - only: /^([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/ - branches: - ignore: /.*/ diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..dc90e5a --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,17 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security +# Label to use when marking an issue as stale +staleLabel: wontfix +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6ec9b4e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,75 @@ +name: Build and Publish + +on: + push: + branches: + - master + tags: + - 'v*.*.*' + pull_request: + branches: + - master + workflow_dispatch: + branches: + - master + + +jobs: + build-and-push-docker-image: + name: Build and Push Docker Image + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: | + sameersbn/postgresql + quay.io/sameersbn/postgresql + ghcr.io/sameersbn/postgresql + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + latest + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to Github Packages + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to Quay.io + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_TOKEN }} + + - name: Build image and push to container registries + uses: docker/build-push-action@v2 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }}