Skip to content

Commit

Permalink
feat: add deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
raisedadead committed May 21, 2024
1 parent b50a934 commit 68409f0
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Deploy

on:
workflow_dispatch:
push:
branches:
- main

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

strategy:
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3

- name: Create a tagname
id: tagname
run: |
echo "tagname=$(git rev-parse --short HEAD)-$(date +%Y%m%d)-$(date +%H%M)" >> $GITHUB_ENV
- name: Build & Tag Images
run: |
docker build . \
--tag registry.digitalocean.com/${{ secrets.DOCR_NAME }}/org/hashnode-preview:$tagname \
--tag registry.digitalocean.com/${{ secrets.DOCR_NAME }}/org/hashnode-preview:latest
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}

- name: Log in to DigitalOcean Container Registry with short-lived credentials
run: doctl registry login --expiry-seconds 1200

- name: Push image to DigitalOcean Container Registry
run: |
docker push --all-tags registry.digitalocean.com/${{ secrets.DOCR_NAME }}/org/hashnode-preview

0 comments on commit 68409f0

Please sign in to comment.