From 7da6147eb81dfe350ff4ba0f88298349a110fd8a Mon Sep 17 00:00:00 2001 From: dakota002 Date: Tue, 3 Dec 2024 11:10:36 -0500 Subject: [PATCH] Moves docker stuff from deploy into build --- .github/workflows/build.yml | 47 ++++++++++++++++++++++--- .github/workflows/deploy.yml | 67 ------------------------------------ 2 files changed, 43 insertions(+), 71 deletions(-) delete mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a24e2a7..be22636 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,15 +2,54 @@ name: Build and test on: pull_request: + push: + branches: + - main + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} jobs: - docker: - name: Docker tests + build: runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Run tests - run: ./test.sh + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} + type=raw,value={{date 'YYYYMMDD-HHmmss'}}-{{sha}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: amd64,arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: server + platforms: amd64,arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 4b66308..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Deploy - -on: - push: - branches: - - main - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - strategy: - fail-fast: false - matrix: - include: - - env: dev - url: https://dev.gcn.nasa.gov - - env: test - url: https://test.gcn.nasa.gov - - env: prod - url: https://gcn.nasa.gov - environment: - name: ${{ matrix.env }} - url: ${{ matrix.url }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Log in to the Container registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=raw,value=latest,enable=${{ matrix.env == 'dev' }} - type=raw,value=${{ matrix.env }}-{{ date 'YYYYMMDDThhmmss' }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: amd64,arm64 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - context: server - platforms: amd64,arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }}