diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..96a2c48 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,65 @@ +name: Continuous Integration + +on: + push: + branches: [master] + tags: ['v*'] + pull_request: + branches: [master] + +env: + REGISTRY: gitea.lucaswinther.info + +jobs: + docker-build-and-push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + # Scope Node 14 to the build step so subsequent Node 20+ JS actions are unaffected. + # The Dockerfile copies ./build into nginx, so the static build runs before docker build. + - name: Build React application + env: + NODE_VERSION: v14.21.3 + run: | + case "$(uname -m)" in + x86_64) arch=x64 ;; + aarch64) arch=arm64 ;; + *) echo "::error::Unsupported runner architecture $(uname -m)"; exit 1 ;; + esac + curl -fsSL "https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-${arch}.tar.gz" \ + | tar -xz -C "${RUNNER_TEMP:-/tmp}" + export PATH="${RUNNER_TEMP:-/tmp}/node-${NODE_VERSION}-linux-${arch}/bin:$PATH" + npm ci + npm run build + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Gitea's job token cannot publish packages; use a package-write PAT. + - name: Log in to Gitea Container Registry + if: gitea.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: lucasw89 + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/lucasw89/chess-swap-frontend + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=ref,event=branch + type=semver,pattern={{version}} + type=sha,prefix=sha- + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: ${{ gitea.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 949f2a8..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,47 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: CI - -# Controls when the action will run. -on: - # Triggers the workflow on push or pull request events but only for the master branch - push: - branches: [ master ] - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - - name: Setup Node.js environment - uses: actions/setup-node@v2.1.4 - - - name: Install required components - run: npm install - - # Runs a single command using the runners shell - - name: use react-scripts to create optimized build - run: npm run build - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Publish changed images - uses: dawidd6/action-docker-publish-changed@v3 - with: - username: ${{secrets.DOCKERHUB_USERNAME}} - password: ${{secrets.DOCKERHUB_TOKEN}} - platforms: linux/amd64,linux/arm64,linux/arm - tag: latest diff --git a/Dockerfile b/Dockerfile index 291b947..bd9dbcc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,2 @@ -FROM nginx:latest +FROM nginx:1.30.6-trixie COPY ./build /usr/share/nginx/html \ No newline at end of file