Reduce CPU usage on DO (#23) #118
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Mirror Bot CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dym-ok/pre-commit-action@v1 | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Build image | |
run: docker build -t "${{ secrets.DO_image }}" . | |
- name: Save Docker image | |
run: docker save --output image.tar "${{ secrets.DO_image }}" | |
- name: Upload docker image artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: docker-artifact | |
path: image.tar | |
if-no-files-found: error | |
retention-days: 1 | |
deploy: | |
if: github.ref == 'refs/heads/main' | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Retrieve uploaded Docker image from previous build | |
uses: actions/download-artifact@v3 | |
with: | |
name: docker-artifact | |
- name: Load Docker image | |
run: docker load --input image.tar | |
- name: Install doctl | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: ${{ secrets.DIGITAL_OCEAN_TOKEN }} | |
- name: Log into Digital Ocean Container Registry | |
run: doctl registry login --expiry-seconds 600 | |
- name: Push image to Digital Ocean Container Registry | |
run: docker push "${{ secrets.DO_image }}" |