name: Dev deployment
on:
workflow_call:
secrets:
APP_ID:
required: true
APP_PRIVATE_KEY:
required: true
workflow_dispatch:
permissions:
contents: read
concurrency:
group: fynd-dev-promotion
cancel-in-progress: false
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/fynd
jobs:
authorize:
name: Authorize manual deployer
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Verify maintainer permission for manual deployment
if: github.event_name == 'workflow_dispatch'
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b with:
script: |
const actors = [...new Set([context.actor, process.env.GITHUB_TRIGGERING_ACTOR].filter(Boolean))];
for (const actor of actors) {
const { data: { permission } } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: actor,
});
if (!['maintain', 'admin', 'write'].includes(permission)) {
throw new Error(`Manual Dev deployment requires maintain or admin permission; ${actor} has ${permission}.`);
}
}
build:
name: Build and push Dev image
needs: authorize
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd
- name: Log in to GitHub Container Registry
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Linux/amd64 image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 with:
context: .
platforms: linux/amd64
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:sha-${{ github.sha }}
promote:
name: Promote to Dev
needs: build
permissions:
contents: read
uses: propeller-heads/ci-cd-templates/.github/workflows/promote-to-dev.yaml@fdb653920a261cb675e3fdd92de79e833c11dbcf
with:
image_name: fynd
image_tag: sha-${{ github.sha }}
environment: dev
secrets:
app_id: ${{ secrets.APP_ID }}
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}