From 49aae062efd4f4eaea78ef45a35028c9e5837192 Mon Sep 17 00:00:00 2001 From: maddalax Date: Thu, 10 Oct 2024 17:01:38 -0500 Subject: [PATCH] hn clone --- .github/workflows/release-hn-clone.yml | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/release-hn-clone.yml diff --git a/.github/workflows/release-hn-clone.yml b/.github/workflows/release-hn-clone.yml new file mode 100644 index 0000000..91183a4 --- /dev/null +++ b/.github/workflows/release-hn-clone.yml @@ -0,0 +1,49 @@ +name: Build and Deploy htmgo hackernews clone + +on: + workflow_dispatch: # Trigger on manual workflow_dispatch + push: + branches: + - master # Trigger on pushes to master + paths: + - 'hackernews/**' # Trigger only if files in this directory change + - "framework/**" + - "framework-ui/**" + - "cli/**" + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get short commit hash + id: vars + run: echo "::set-output name=short_sha::$(echo $GITHUB_SHA | cut -c1-7)" + + - name: Build Docker image + run: | + cd ./examples/hackernews && docker build -t ghcr.io/${{ github.repository_owner }}/hackernews:${{ steps.vars.outputs.short_sha }} . + + - name: Tag as latest Docker image + run: | + docker tag ghcr.io/${{ github.repository_owner }}/hackernews:${{ steps.vars.outputs.short_sha }} ghcr.io/${{ github.repository_owner }}/hackernews:latest + + - name: Log in to GitHub Container Registry + run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Push Docker image + run: | + docker push ghcr.io/${{ github.repository_owner }}/hackernews:latest