From 57977815d2a32f3acc68639db025037f4f5948ad Mon Sep 17 00:00:00 2001 From: Nicholas Orlowsky Date: Tue, 17 Jan 2023 12:14:18 -0600 Subject: [PATCH] Added NWS deployment script --- .github/workflows/nws-deploy.yaml | 82 +++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/nws-deploy.yaml diff --git a/.github/workflows/nws-deploy.yaml b/.github/workflows/nws-deploy.yaml new file mode 100644 index 0000000..49cca2a --- /dev/null +++ b/.github/workflows/nws-deploy.yaml @@ -0,0 +1,82 @@ +name: NWS Publish React JS + +on: + push: + branches: [ "main" ] + repository_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Create Dockerfile + run: | + cat <<\EOT > Dockerfile + FROM node:13.12.0-alpine as build + WORKDIR /app + ENV PATH /app/node_modules/.bin:$PATH + COPY package.json ./ + COPY package-lock.json ./ + RUN npm install + + RUN npm install react-scripts@3.4.1 -g --silent + COPY . ./ + RUN npm run build + + # production environment + FROM nginx:stable-alpine + COPY --from=build /app/build /usr/share/nginx/html + COPY --from=build /app/nginx/nginx.conf /etc/nginx/conf.d/default.conf + EXPOSE 80 + CMD ["nginx", "-g", "daemon off;"] + EOT + + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Setup Python + uses: actions/setup-python@v4.0.0 + with: + python-version: 3.12.0-alpha.3 + + - uses: paulhatch/semantic-version@v5.0.2 + id: vnum + with: + tag_prefix: "" + major_pattern: "(MAJOR)" + minor_pattern: "(MINOR)" + version_format: "${major}.${minor}.${patch}-${increment}" + bump_each_commit: true + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.vnum.outputs.version_tag }} + ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}