From 2785a5ca9b7552710300a67da99e8d0855db444a Mon Sep 17 00:00:00 2001 From: mwood77 <43637076+mwood77@users.noreply.github.com> Date: Mon, 1 Apr 2024 16:45:10 +0200 Subject: [PATCH] Add CI pipeline (#24) * name pipelines correctly and add CI action * tweaks --- .github/workflows/cd.yml | 53 ++++++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 52 +++++++++------------------------------ 2 files changed, 64 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..ae3bcf1 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,53 @@ +name: cd + +on: + workflow_dispatch: + push: + branches: + - 'main' + release: + types: [published] + +jobs: + build_push_to_registry: + name: Build/Push Image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/pf2opn + tags: | + type=semver,pattern={{version}} + # dynamically set the branch name as a prefix + type=sha,prefix={{branch}}- + # dynamically set the branch name + type=raw,value={{branch}}-latest + # set the latest branch name + type=raw,value=latest + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83a85b9..f2e89fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,53 +1,23 @@ name: ci on: + pull_request: workflow_dispatch: - push: - branches: - - 'main' - release: - types: [published] + jobs: - build_push_to_registry: - name: Build/Push Image to Docker Hub + build: runs-on: ubuntu-latest + steps: - - name: Check out the repo + - name: Checkout uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Setup Node Environment + uses: actions/setup-node@v4 - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ secrets.DOCKERHUB_USERNAME }}/pf2opn - tags: | - type=semver,pattern={{version}} - # dynamically set the branch name as a prefix - type=sha,prefix={{branch}}- - # dynamically set the branch name - type=raw,value={{branch}}-latest - # set the latest branch name - type=raw,value=latest + - name: Install Dependencies + uses: npm ci - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + - name: Build project + uses: npm run build