diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0fc4294 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +# Items that don't need to be in a Docker image. +# Anything not used by the build system should go here. +.* +Dockerfile +README.md + +# Artifacts that will be built during image creation. +# This should contain all files created during `npm run build`. +node_modules diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index d426cb9..a7874b1 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -8,27 +8,40 @@ concurrency: group: cd-${{ github.ref }} cancel-in-progress: false -# env: -# REPO_URL: ghcr.io -# REPO_PROJECT: swiftdrivecorp -# REPO_CONFIG: infra-deploy - -# ghcr.io/swiftdrivecorp/frontend-admin-staging:123456 -# ghcr.io/swiftdrivecorp/frontend-admin-prodution:123456 - jobs: - test: - name: "Extract environment name" + build-and-push: + name: "Build and push docker image" runs-on: ubuntu-latest outputs: - swf-environment: ${{ steps.extract.outputs.environment }} + environment: ${{ steps.extract.outputs.environment }} steps: - id: extract - run: echo "swf-environment=$([[ '${{ github.event.action }}' == 'prereleased' ]] && echo 'staging' || echo 'production')" >> $GITHUB_OUTPUT - - id: test - run: 'echo "Extracted environment name: $EXTRACTED"' + name: Extract environment + run: echo "environment=$([[ '${{ github.event.action }}' == 'prereleased' ]] && echo 'staging' || echo 'production')" >> $GITHUB_OUTPUT + + - name: Print environment + run: 'echo "Extracted environment: $EXTRACTED"' env: - EXTRACTED: ${{ steps.extract.outputs.swf-environment }} + EXTRACTED: ${{ steps.extract.outputs.environment }} + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build docker image + run: | + docker build -t ghcr.io/killmenot/github-test-${{ steps.extract.outputs.environment }}:${{ github.event.release.tag_name }} -f Dockerfile . + + - name: Push docker image to GitHub Container Registry + run: | + docker push ghcr.io/killmenot/github-test-${{ steps.extract.outputs.environment }}:${{ github.event.release.tag_name }} + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..626906c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM nginx:1.25.4-alpine + +COPY /static /usr/share/nginx/html +RUN chown nginx.nginx /usr/share/nginx/html/ -R + +EXPOSE 80 diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..56db817 --- /dev/null +++ b/static/index.html @@ -0,0 +1,2 @@ +

Hello World

+h1>