diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 0bbb828..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: "Manual Build" -on: - workflow_dispatch: - inputs: - version: - type: string - description: "Version Number" - required: true -jobs: - build: - runs-on: ubuntu-latest - name: "${{ github.event.inputs.version }} / ${{ matrix.arch }}" - strategy: - matrix: - arch: ["aarch64", "amd64", "armhf", "armv7", "i386"] - - steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.10.0 - with: - all_but_latest: true - access_token: ${{ github.token }} - - - name: Check out repository - uses: actions/checkout@v3 - - - name: Login to DockerHub - uses: docker/login-action@v2.0.0 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build & Push to Dockerhub - uses: home-assistant/builder@2022.07.0 - with: - args: | - --${{ matrix.arch }} \ - --version ${{ github.event.inputs.version }} \ - --target . diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index e6fa102..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,76 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ main ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ main ] - schedule: - - cron: '29 23 * * 0' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'javascript', 'python' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://git.io/codeql-language-support - - steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.10.0 - with: - all_but_latest: true - access_token: ${{ github.token }} - - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # â„šī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/commit-build.yml b/.github/workflows/commit-build.yml new file mode 100644 index 0000000..b402fad --- /dev/null +++ b/.github/workflows/commit-build.yml @@ -0,0 +1,83 @@ +name: Commit Build +on: + workflow_dispatch: + inputs: + version: + type: string + description: "Version Number" + push: + branch: [main] +jobs: + metadata: + runs-on: ubuntu-latest + name: Metadata + outputs: + version: ${{ steps.version.outputs.VERSION }} + steps: + - name: Check out repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Get Version + id: version + shell: bash + run: | + if [ -z "${INPUT_VERSION}" ]; then + echo ::set-output name=VERSION::$(git describe --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g') + else + echo ::set-output name=VERSION::${INPUT_VERSION} + fi + env: + INPUT_VERSION: ${{ github.event.inputs.version }} + - name: ${{ steps.version.outputs.VERSION }} + shell: bash + run: | + echo ${{ steps.version.outputs.VERSION }} + + deploy: + runs-on: ubuntu-latest + name: Build & Publish ${{ matrix.arch }} / ${{ needs.metadata.outputs.version }} + if: github.event_name != 'pull_request' + needs: + - metadata + strategy: + matrix: + arch: ["aarch64", "amd64", "armhf", "armv7", "i386"] + + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.10.0 + with: + all_but_latest: true + access_token: ${{ github.token }} + + - name: Check out repository + uses: actions/checkout@v3 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: "yarn" + cache-dependency-path: webapp/yarn.lock + + - name: Login to DockerHub + uses: docker/login-action@v2.0.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: "Save version number" + run: echo "REACT_APP_BUILD_VERSION=${{ needs.metadata.outputs.version }}" > ./webapp/.env.production + + - name: "Build Web" + run: cd webapp && yarn install && yarn build + + - name: Build & Push to Dockerhub - ${{ matrix.arch }} / ${{ needs.metadata.outputs.version }} + uses: home-assistant/builder@2022.07.0 + with: + args: | + --${{ matrix.arch }} \ + --no-latest \ + --version ${{ needs.metadata.outputs.version }} \ + --target . diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6a1821b..25e917c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,10 @@ -name: Tests +name: Commit Tests on: push: - branch: + branch: - main pull_request: - branch: + branch: - main jobs: metadata: @@ -72,40 +72,3 @@ jobs: run: cd webapp && yarn install - name: ${{ needs.metadata.outputs.version }} / ${{ matrix.action }} run: cd webapp && yarn ${{ matrix.action }} - - deploy: - runs-on: ubuntu-latest - name: Build & Publish ${{ matrix.arch }} - if: github.event_name != 'pull_request' - needs: - - metadata - - nodejs - - python - strategy: - matrix: - arch: ["aarch64", "amd64", "armhf", "armv7", "i386"] - - steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.10.0 - with: - all_but_latest: true - access_token: ${{ github.token }} - - - name: Check out repository - uses: actions/checkout@v3 - - - name: Login to DockerHub - uses: docker/login-action@v2.0.0 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build & Push to Dockerhub - ${{ matrix.arch }} / ${{ needs.metadata.outputs.version }} - uses: home-assistant/builder@2022.07.0 - with: - args: | - --${{ matrix.arch }} \ - --no-latest \ - --version ${{ needs.metadata.outputs.version }} \ - --target . diff --git a/Dockerfile b/Dockerfile index 56d0dcc..77a6fc0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,6 @@ # <--- Pre-Build Args --> ARG BUILD_ARCH -# <--- Web builder --> -FROM node:16 AS web-builder - -# <--- Post-Build Args --> -ARG BUILD_VERSION - -RUN npm i -g yarn - -WORKDIR /web-builder -COPY webapp/ /web-builder - -# Build web -RUN echo "REACT_APP_BUILD_VERSION=${BUILD_VERSION}" > /web-builder/.env.production -RUN yarn && yarn build - # <--- Main Image --> FROM python:3.9.13-slim-buster WORKDIR /app @@ -45,7 +30,7 @@ RUN /app/bin/build.sh /app # <--- Api Code --> COPY api/src /app/src -COPY --from=web-builder /web-builder/build /app/web +COPY /webapp/build /app/web # <--- Ports --> EXPOSE 8000 diff --git a/Makefile b/Makefile index 9bc4470..8d9cd9d 100644 --- a/Makefile +++ b/Makefile @@ -15,9 +15,11 @@ build-with-builder: -t /data build: + cd webapp && yarn build $(DC) build build-no-cache: + cd webapp && yarn buil $(DC) build --no-cache push: