diff --git a/.github/actions/docker-build/action.yml b/.github/actions/docker-build/action.yml new file mode 100644 index 0000000..0597cec --- /dev/null +++ b/.github/actions/docker-build/action.yml @@ -0,0 +1,60 @@ +name: Docker build +inputs: + image_name: + required: true + type: string + dockerhub_username: + required: true + type: string + dockerhub_token: + required: true + dockerfile: + type: string + default: Dockerfile + context: + type: string + default: . + +runs: + using: "composite" + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + # list of Docker images to use as base name for tags + images: | + ${{ inputs.image_name }} + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=sha + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + username: ${{ inputs.dockerhub_username }} + password: ${{ inputs.dockerhub_token }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + file: ${{ inputs.dockerfile }} + context: ${{ inputs.context }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index a5adb1f..7db17d4 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -18,49 +18,16 @@ on: secrets: dockerhub_token: required: true + type: string jobs: docker: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - # list of Docker images to use as base name for tags - images: | - ${{ inputs.image_name }} - # generate Docker tags based on the following events/attributes - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=sha - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - username: ${{ inputs.dockerhub_username }} - password: ${{ secrets.dockerhub_token }} - - - name: Build and push - uses: docker/build-push-action@v4 + - uses: geokrety/geokrety-gha-workflows/.github/actions/docker-build@main with: - file: ${{ inputs.dockerfile }} + image_name: ${{ inputs.image_name }} + dockerhub_username: ${{ inputs.dockerhub_username }} + dockerhub_token: ${{ secrets.dockerhub_token }} + dockerfile: ${{ inputs.dockerfile }} context: ${{ inputs.context }} - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/release.yml b/.github/workflows/semantic-release.yml similarity index 62% rename from .github/workflows/release.yml rename to .github/workflows/semantic-release.yml index aac9475..4be48dc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/semantic-release.yml @@ -10,16 +10,16 @@ on: required: true jobs: - pre-commit: - if: "!contains(github.event.head_commit.message, 'skip ci')" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: geokrety/geokrety-gha-workflows/.github/actions/pre-commit@main + # pre-commit: + # if: "!contains(github.event.head_commit.message, 'skip ci')" + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # - uses: geokrety/geokrety-gha-workflows/.github/actions/pre-commit@main semantic-release: if: "!contains(github.event.head_commit.message, 'skip ci')" - needs: pre-commit + # needs: pre-commit runs-on: ubuntu-latest steps: - uses: actions/checkout@v3