From 32e2189f063d9282e0992cbf5be92e343231beda Mon Sep 17 00:00:00 2001 From: DitchTurtL Date: Mon, 16 Dec 2024 22:36:59 +0000 Subject: [PATCH] Adding github action --- .github/workflows/docker-deploy.yml | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/docker-deploy.yml diff --git a/.github/workflows/docker-deploy.yml b/.github/workflows/docker-deploy.yml new file mode 100644 index 0000000..92ae353 --- /dev/null +++ b/.github/workflows/docker-deploy.yml @@ -0,0 +1,43 @@ +name: Build and Deploy to GitHub Packages + +on: + push: + branches: + - main # Adjust to your default branch + workflow_dispatch: # Allows manual triggering of the workflow + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + # Step 1: Checkout the repository + - name: Checkout code + uses: actions/checkout@v3 + + # Step 2: Log in to GitHub Container Registry + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Step 3: Set up Docker Buildx for multi-platform builds (optional but recommended) + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + # Step 4: Build and push the Docker image to GitHub Container Registry + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: Dockerfile + push: true + tags: | + ghcr.io/${{ github.repository_owner }}/osf-site:latest + ghcr.io/${{ github.repository_owner }}/osf-site:${{ github.sha }} + + # Step 5: Optional - Clean up unused Docker resources on the runner + - name: Prune Docker + run: docker system prune --all --force