From 354f389525f4364ca4cf560b6174d80c1551f570 Mon Sep 17 00:00:00 2001 From: Emmanuel Owosekun Date: Wed, 28 Aug 2024 19:14:01 +0200 Subject: [PATCH] Add: pushes greenbone-feed-sync image to harbor --- .github/workflows/container.yml | 71 +++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 12 deletions(-) diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index 94dccb4..e99c1af 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -7,28 +7,59 @@ on: workflow_dispatch: jobs: - images: - name: Build images - runs-on: ubuntu-latest - + generate: + name: generate greenbone-feed-sync archive + runs-on: + - self-hosted + - self-hosted-generic + outputs: + labels: ${{ steps.meta.outputs.labels }} + feed-info: ${{ steps.feed-info.outputs.feed-version }} steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Login to Dockerhub Container Registry - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 + - name: Determine Feed Info + id: feed-info + run: | + echo "feed-version=$(date +"%Y%m%d%H%M")" >> $GITHUB_OUTPUT + - name: upload greenbone-feed-sync archive + uses: actions/upload-artifact@v4 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + name: greenbone-feed-sync + path: . - name: Setup container meta information - id: meta + id: labels uses: docker/metadata-action@v5 with: - images: ${{ github.repository }} labels: | org.opencontainers.image.vendor=Greenbone org.opencontainers.image.documentation=https://greenbone.github.io/docs/ org.opencontainers.image.base.name=debian:stable-slim + + ghcr: + needs: generate + name: Build and push to ghcr.io (for feed-deployment only!!!) + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: greenbone/actions/checkout@v3 + - name: Clean directory + run: rm -rf ${{ matrix.FEED_TYPE }}/* + - uses: actions/download-artifact@v4 + with: + name: greenbone-feed-sync + - name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ vars.IMAGE_REGISTRY }} + username: ${{ secrets.GREENBONE_BOT }} + password: ${{ secrets.GREENBONE_BOT_PACKAGES_WRITE_TOKEN }} + - name: Setup additional container meta information + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} tags: | # create container tag for git tags type=ref,event=tag @@ -46,4 +77,20 @@ jobs: file: .docker/Dockerfile platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + labels: ${{ needs.generate.outputs.labels }} + + harbor: + name: Build and push to self-hosted harbor + needs: generate + uses: greenbone/workflows/.github/workflows/container-build-push-feed.yml@main + with: + artifact-name: greenbone-feed-sync + artifact-path: community + build-context: community + image-labels: ${{ needs.generate.outputs.labels }} + image-tags: | + type=raw,value=community + type=raw,value=latest + type=raw,value=${{ needs.generate.outputs.feed-info }} + image-url: community/greenbone-feed-sync + secrets: inherit