From 53ecbf90161c1223428e617b6b7e9ecdc36a1950 Mon Sep 17 00:00:00 2001 From: leukosaima <187358+leukosaima@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:40:47 -0500 Subject: [PATCH] go back to one github workflow --- .github/workflows/ci.yml | 38 ++++++++++++++++ .github/workflows/docker-cicd.yml | 73 ------------------------------- 2 files changed, 38 insertions(+), 73 deletions(-) delete mode 100644 .github/workflows/docker-cicd.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d91a461..693b687b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,10 +5,14 @@ on: pull_request: branches: - main + push: + branches: + - main env: # We do not need Husky hooks installed for this workflow. HUSKY: 0 + IMAGENAME: registry.digitalocean.com/nsgcr/netrunner-cards-json jobs: format_and_lint_and_test: @@ -31,3 +35,37 @@ jobs: - name: Test run: npm run test + + build_and_push: + name: Build docker image + needs: [format_and_lint_and_test] + runs-on: ubuntu-latest + steps: + + - name: Checkout the repo + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build image + run: docker build -t $IMAGENAME:latest . + + - name: Install doctl + if: github.ref == 'refs/heads/main' + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + + - name: Log in to DO Container Registry + if: github.ref == 'refs/heads/main' + run: doctl registry login --expiry-seconds 600 + + - name: Tag image with run id + if: github.ref == 'refs/heads/main' + run: + docker tag $IMAGENAME:latest $IMAGENAME:${{ github.run_id }} + + - name: Push image to DO Container Registry + if: github.ref == 'refs/heads/main' + run: docker push $IMAGENAME:${{ github.run_id }} && docker push $IMAGENAME:latest diff --git a/.github/workflows/docker-cicd.yml b/.github/workflows/docker-cicd.yml deleted file mode 100644 index cee2bf81..00000000 --- a/.github/workflows/docker-cicd.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: docker-cicd - -on: - push: - branches: - - main - -env: - # We do not need Husky hooks installed for this workflow. - HUSKY: 0 - -jobs: - format_and_lint_and_test: - name: Format, Lint, Test - runs-on: ubuntu-latest - steps: - - - name: Checkout the repo - uses: actions/checkout@v2 - - - name: Use Node.js - uses: actions/setup-node@v2 - with: - node-version: "18.x" - - - name: Install dependencies - run: npm install - - - name: Format Check - run: npm run format-check - - - name: Lint - run: npm run lint - - - name: Test - run: npm run test - - build_and_push: - name: Docker build and push - needs: format_and_lint_and_test - runs-on: ubuntu-latest - steps: - - - name: Checkout the repo - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build image - run: docker build -t nsgcr/netrunner-cards-json . - - - name: Install doctl - uses: digitalocean/action-doctl@v2 - with: - token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} - - - name: Log in to DO Container Registry - run: doctl registry login --expiry-seconds 600 - - - name: Tag image with run id - run: - docker tag nsgcr/netrunner-cards-json registry.digitalocean.com/nsgcr/netrunner-cards-json:${{ github.run_id }} - - - name: Tag image with latest - run: - docker tag nsgcr/netrunner-cards-json registry.digitalocean.com/nsgcr/netrunner-cards-json:latest - - - name: Push run id tag to DO Container Registry - run: docker push registry.digitalocean.com/nsgcr/netrunner-cards-json:${{ github.run_id }} - - - name: Push latest tag to DO Container Registry - run: docker push registry.digitalocean.com/nsgcr/netrunner-cards-json:latest