From e36b6fe0ce2c86e68fd362ff6ccdcc5b45a5b49a Mon Sep 17 00:00:00 2001 From: Paul Larson Date: Thu, 11 Jan 2024 19:05:45 -0600 Subject: [PATCH] consolidate server github workflows to avoid race --- .../workflows/server-charm-release-edge.yml | 49 +++++++++++++++-- .../workflows/server-publish-oci-image.yml | 53 ------------------- 2 files changed, 45 insertions(+), 57 deletions(-) delete mode 100644 .github/workflows/server-publish-oci-image.yml diff --git a/.github/workflows/server-charm-release-edge.yml b/.github/workflows/server-charm-release-edge.yml index 0e2ac028..98c93a03 100644 --- a/.github/workflows/server-charm-release-edge.yml +++ b/.github/workflows/server-charm-release-edge.yml @@ -8,20 +8,61 @@ on: - server/** workflow_dispatch: +env: + REGISTRY: ghcr.io + jobs: - build: + build-and-push-backend-image: + runs-on: [self-hosted, linux, X64] + permissions: + contents: read + packages: write + + env: + IMAGE_NAME: ${{ github.repository }} + + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + config-inline: | + [registry."docker.io"] + mirrors = ["https://github-runner-dockerhub-cache.canonical.com:5000"] + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push backend Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: ./server + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + build-and-push-charm: name: Release to Charmhub runs-on: [self-hosted, linux, X64] steps: - name: Checkout uses: actions/checkout@v2 - with: - fetch-depth: 0 - name: Upload charm to charmhub uses: canonical/charming-actions/upload-charm@2.4.0 with: charm-path: server/charm credentials: "${{ secrets.CHARMHUB_TOKEN }}" github-token: "${{ secrets.GITHUB_TOKEN }}" - upload-image: "true" channel: "latest/edge" diff --git a/.github/workflows/server-publish-oci-image.yml b/.github/workflows/server-publish-oci-image.yml deleted file mode 100644 index 8946e034..00000000 --- a/.github/workflows/server-publish-oci-image.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Publish Testflinger OCI image to ghcr.io -on: - push: - branches: ["main"] - tags: ["v*.*.*"] - paths: - - server/** - workflow_dispatch: - -env: - REGISTRY: ghcr.io - -jobs: - build-and-push-backend-image: - runs-on: [self-hosted, linux, X64] - permissions: - contents: read - packages: write - - env: - IMAGE_NAME: ${{ github.repository }} - - steps: - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - config-inline: | - [registry."docker.io"] - mirrors = ["https://github-runner-dockerhub-cache.canonical.com:5000"] - - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Log in to the Container registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - name: Build and push backend Docker image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 - with: - context: ./server - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }}