From dfdebb19c32c0fd10a451051f6fe60d42b446bef Mon Sep 17 00:00:00 2001 From: Otto Lote Date: Tue, 23 Apr 2024 15:32:18 +0200 Subject: [PATCH] Add publish container github action and remove old action --- .../workflows/publish-container-image.yaml | 87 +++++++++++++++++++ .github/workflows/publisher.yml | 37 -------- 2 files changed, 87 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/publish-container-image.yaml delete mode 100644 .github/workflows/publisher.yml diff --git a/.github/workflows/publish-container-image.yaml b/.github/workflows/publish-container-image.yaml new file mode 100644 index 0000000..f0ba81f --- /dev/null +++ b/.github/workflows/publish-container-image.yaml @@ -0,0 +1,87 @@ + +name: Docker Image Publish + +on: + push: + branches: [ "main", "ol/containerize" ] + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] + # pull_request: + # branches: [ "main" ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + # Add support for more platforms with QEMU (optional) + # https://github.com/docker/setup-qemu-action + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Version from git describe (https://git-scm.com/docs/git-describe) + - name: Get version + id: version + run: | + output=$(git describe --tags --always --dirty) + echo ::set-output name=git_version::$output + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: downcase REPO + run: | + echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: ./publish + push: ${{ github.event_name != 'pull_request' }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + file: ./publish/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + platforms: linux/amd64,linux/arm/v7,linux/arm64 diff --git a/.github/workflows/publisher.yml b/.github/workflows/publisher.yml deleted file mode 100644 index 0c20719..0000000 --- a/.github/workflows/publisher.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Publish - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -permissions: - contents: read - -jobs: - publish: - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up Python 3.10 - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - - name: Install dependencies - run: | - ls -la - python -m pip install --upgrade pip - pip install -r ./publisher/requirements.txt - - - name: Publish MD files to the Confluence space - env: - LOGIN: ${{secrets.confluence_login }} - PASSWORD: ${{secrets.confluence_password }} - run: | - python3 ./publisher/main.py --login="$LOGIN" --password="$PASSWORD"