From dda7f913a56f6d185cb0fb6e0a2baccde735d1aa Mon Sep 17 00:00:00 2001 From: Jamie Hodgson Date: Mon, 23 Sep 2024 13:43:10 +0200 Subject: [PATCH] github actions --- .github/dependabot.yml | 13 ++++++ .github/workflows/main.yml | 92 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/main.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5ac1513 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +version: 2 +updates: + - package-ecosystem: pip + directory: / + open-pull-requests-limit: 25 + schedule: + interval: weekly + + - package-ecosystem: npm + directory: / + open-pull-requests-limit: 25 + schedule: + interval: weekly diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..a9ea4f2 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,92 @@ +name: Build and Deploy + +on: + push: + tags: + - "v*" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node packages + run: npm install + + - name: Build assets + run: npm run build + env: + NODE_ENV: production + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + push: true + context: . + file: Dockerfile + tags: ghcr.io/jamie-mh/stratumwebsite:latest,ghcr.io/jamie-mh/stratumwebsite:${{ github.ref_name }} + + deploy: + runs-on: ubuntu-latest + needs: build + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up SSH + run: | + mkdir ~/.ssh + echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/deploy.key + chmod 700 ~/.ssh + chmod 600 ~/.ssh/deploy.key + + cat >>~/.ssh/config <