From 13f36c87c8ee34e3ab5dc3de2192430febbe6b02 Mon Sep 17 00:00:00 2001 From: whichnode <152212254+whichnode@users.noreply.github.com> Date: Sat, 26 Oct 2024 09:42:17 -0600 Subject: [PATCH] Add CI workflow for API container image, clean up web app image job (#60) * Add CI jobs for web app and api container images * Remove unnecessary permissions * Add Bull Board container image build workflow * Reproduce typo * Fix typo * Trigger build --- .github/workflows/build-api-container.yml | 47 +++++++++++ .../workflows/build-bull-board-container.yml | 46 ++++++++++ .github/workflows/build-web-app-container.yml | 46 ++++++++++ .github/workflows/build-web-app.yml | 84 ------------------- 4 files changed, 139 insertions(+), 84 deletions(-) create mode 100644 .github/workflows/build-api-container.yml create mode 100644 .github/workflows/build-bull-board-container.yml create mode 100644 .github/workflows/build-web-app-container.yml delete mode 100644 .github/workflows/build-web-app.yml diff --git a/.github/workflows/build-api-container.yml b/.github/workflows/build-api-container.yml new file mode 100644 index 0000000..4d6ac0f --- /dev/null +++ b/.github/workflows/build-api-container.yml @@ -0,0 +1,47 @@ +name: Build API Container Image + +on: + push: + paths: + - api/** + - .github/workflows/build-api-container.yml + branches: + - main + - build-test + +jobs: + build: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/${{ github.repository }}/api + tags: | + type=sha,enable=true,priority=100,prefix=,suffix=,format=long + + - name: Log in to Container Image Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: ./api + file: ./api/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + CI_COMMIT_SHA=${{ github.sha }} + diff --git a/.github/workflows/build-bull-board-container.yml b/.github/workflows/build-bull-board-container.yml new file mode 100644 index 0000000..8ac14bf --- /dev/null +++ b/.github/workflows/build-bull-board-container.yml @@ -0,0 +1,46 @@ +name: Build Bull Board Container Image + +on: + push: + paths: + - packages/bull-board/** + - .github/workflows/build-bull-board-container.yml + branches: + - main + - build-test + +jobs: + build: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/${{ github.repository }}/bull-board + tags: | + type=sha,enable=true,priority=100,prefix=,suffix=,format=long + + - name: Log in to Container Image Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: ./pacakges/bull-board + file: ./pacakges/bull-board/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + CI_COMMIT_SHA=${{ github.sha }} diff --git a/.github/workflows/build-web-app-container.yml b/.github/workflows/build-web-app-container.yml new file mode 100644 index 0000000..1ae2533 --- /dev/null +++ b/.github/workflows/build-web-app-container.yml @@ -0,0 +1,46 @@ +name: Build Web App Container Image + +on: + push: + paths: + - web-app/** + - .github/workflows/build-web-app-container.yml + branches: + - main + - build-test + +jobs: + build: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/${{ github.repository }}/web-app + tags: | + type=sha,enable=true,priority=100,prefix=,suffix=,format=long + + - name: Log in to Container Image Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: ./web-app + file: ./web-app/docker/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + CI_COMMIT_SHA=${{ github.sha }} diff --git a/.github/workflows/build-web-app.yml b/.github/workflows/build-web-app.yml deleted file mode 100644 index 3d0f031..0000000 --- a/.github/workflows/build-web-app.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: Build Web App - -on: - push: - paths: - - web-app/** - - .github/workflows/build-web-app.yml - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: write - packages: write - pull-requests: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ghcr.io/0lnetworkcommunity/explorer/web-app - tags: | - type=sha,enable=true,priority=100,prefix=,suffix=,format=long - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: ./web-app - file: ./web-app/docker/Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - CI_COMMIT_SHA=${{ github.sha }} - - # - name: Render k8s manifests - # run: | - # export GITHUB_SHA="${{ github.sha }}" - - # envsubst < .templates/infra/web-app/deployment.yaml > infra/web-app/deployment.yaml - - # git config --global user.name 'github-actions' - # git config --global user.email 'github-actions@github.com' - - # git add infra/web-app/deployment.yaml - - # git commit -m "Update web-app deployment" || echo "No changes to commit" - # git push origin ${{ github.ref_name }}:ci-deployment -f - - # - name: Create Pull Request - # uses: actions/github-script@v6 - # with: - # script: | - # const { repo, owner } = context.repo; - # const result = await github.rest.pulls.create({ - # title: '[Example] Simple demo', - # owner, - # repo, - # head: '${{ github.ref_name }}', - # base: 'main', - # body: [ - # 'This PR is auto-generated by', - # '[actions/github-script](https://github.com/actions/github-script).' - # ].join('\n') - # }); - # github.rest.issues.addLabels({ - # owner, - # repo, - # issue_number: result.data.number, - # labels: ['feature', 'automated pr'] - # }); \ No newline at end of file