Skip to content

misc(ci/cd): Use stdin-pass to login to ghcr & change latest tag to dev #6

misc(ci/cd): Use stdin-pass to login to ghcr & change latest tag to dev

misc(ci/cd): Use stdin-pass to login to ghcr & change latest tag to dev #6

Workflow file for this run

name: Build xyzuan-api-v2 Development Build
on:
push:
branches:
- dev
# pull_request:
# branches:
# - main
jobs:
build:
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
run: echo "${{ secrets.GH_TOKEN }}" | docker login -u "${{ github.actor }}" ghcr.io --password-stdin
- name: Build Docker image
run: |
docker build \
--build-arg PORT=3121 \
--build-arg NODE_ENV=dev \
--build-arg DOMAIN=xyzuan.my.id \
--build-arg PASSWORD_PEPPER=${{ secrets.PASSWORD_PEPPER }} \
--build-arg DATABASE_URL=${{ secrets.DATABASE_URL_DEV }} \
--build-arg GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} \
--build-arg GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} \
--build-arg GITHUB_CLIENT_ID=${{ secrets.GH_CLIENT_ID }} \
--build-arg GITHUB_CLIENT_SECRET=${{ secrets.GH_CLIENT_SECRET }} \
--build-arg LINKEDIN_CLIENT_ID=${{ secrets.LINKEDIN_CLIENT_ID }} \
--build-arg LINKEDIN_CLIENT_SECRET=${{ secrets.LINKEDIN_CLIENT_SECRET }} \
--build-arg TELEGRAM_TOKEN=${{ secrets.TELEGRAM_TOKEN }} \
--build-arg TELEGRAM_CHAT_ID=${{ secrets.TELEGRAM_CHAT_ID }} \
--build-arg CLOUDINARY_CLOUD_NAME=${{ secrets.CLOUDINARY_CLOUD_NAME }} \
--build-arg CLOUDINARY_API_KEY=${{ secrets.CLOUDINARY_API_KEY }} \
--build-arg CLOUDINARY_API_SECRET=${{ secrets.CLOUDINARY_API_SECRET }} \
-t ghcr.io/xyzuan/xyzuan_api_v2:dev -f misc/Dockerfile.dev .
- name: Tag Docker image
run: |
IMAGE_NAME=ghcr.io/xyzuan/xyzuan_api_v2
docker tag $IMAGE_NAME:dev $IMAGE_NAME:$(echo "${{ github.sha }}" | head -c 7)
- name: Push Docker image
run: |
docker push ghcr.io/xyzuan/xyzuan_api_v2:dev
docker push ghcr.io/xyzuan/xyzuan_api_v2:$(echo "${{ github.sha }}" | head -c 7)