diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml new file mode 100644 index 0000000..0974f38 --- /dev/null +++ b/.github/workflows/release-dev.yml @@ -0,0 +1,84 @@ +name: Release on Tag Push + +on: + push: + tags: + - 'v*.*.*' + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + cache: yarn + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Run tests (TODO) + run: | + echo "TODO: Add test execution step here" + + - name: Create .env file + run: | + GIT_TAG=${GITHUB_REF#refs/tags/} + SHORT_SHA=$(git rev-parse --short HEAD) + echo "PORT=3000" >> .env + echo "JWT_SECRET=your_jwt_secret" >> .env + echo "JWT_ACCESS_EXPIRATION_MINUTES=30" >> .env + echo "JWT_REFRESH_EXPIRATION_DAYS=30" >> .env + echo "SMTP_HOST=email-server" >> .env + echo "SMTP_PORT=587" >> .env + echo "SMTP_USERNAME=email-server-username" >> .env + echo "SMTP_PASSWORD=email-server-password" >> .env + echo "EMAIL_FROM=support@yourapp.com" >> .env + echo "UPLOAD_PATH=./data/upload" >> .env + echo "MONGODB_URL=mongodb://127.0.0.1:27017/test-db" >> .env + echo "UPLOAD_PORT=4000" >> .env + echo "UPLOAD_DOMAIN=http://localhost" >> .env + echo "UPLOAD_PATH=./upload-data" >> .env + echo "TAG=dev-${SHORT_SHA}-${GIT_TAG}" >> .env + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Load TAG from .env + run: source .env && echo "TAG=$TAG" >> $GITHUB_ENV + + - name: Build only services with build context + run: | + echo "🔧 Building with tag: $TAG" + docker compose --env-file .env -f docker-compose.yml -f docker-compose.dev.yml build playground-be upload + + - name: Push images with dev-- + run: | + echo "🚀 Pushing images:" + echo " ghcr.io/${{ github.repository_owner }}/playground-be:$TAG" + echo " ghcr.io/${{ github.repository_owner }}/upload:$TAG" + docker push ghcr.io/${{ github.repository_owner }}/playground-be:$TAG + docker push ghcr.io/${{ github.repository_owner }}/upload:$TAG + + - name: Create GitHub Release + continue-on-error: true + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ github.ref_name }} + name: Release ${{ github.ref_name }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 000538b..79c1855 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,5 +1,8 @@ services: playground-be: + build: + context: . + image: ghcr.io/${GITHUB_REPOSITORY_OWNER}/playground-be:${TAG} command: yarn dev -L volumes: - .:/usr/src/playground-be @@ -8,11 +11,14 @@ services: - .env upload: + build: + context: . + image: ghcr.io/${GITHUB_REPOSITORY_OWNER}/upload:${TAG} command: npm start restart: no env_file: - .env - + playground-db: ports: - "27017:27017"