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: Build and Deploy htmgo.dev | |
on: | |
push: | |
branches: | |
- master # Trigger on pushes to master | |
paths: | |
- 'htmgo-site/**' # Trigger only if files in this directory change | |
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 ./htmgo-site && docker build -t ghcr.io/${{ github.repository_owner }}/htmgo-site:${{ steps.vars.outputs.short_sha }} . | |
- 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 }}/htmgo-site:${{ steps.vars.outputs.short_sha }} | |
- name: Create Git tag | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git tag ${{ steps.vars.outputs.short_sha }} | |
git push origin ${{ steps.vars.outputs.short_sha }} |