List and get environments (#15) #5
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: API deploy | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
permissions: | |
id-token: write | |
contents: write | |
jobs: | |
changes: | |
name: Repository changes | |
runs-on: ubuntu-20.04 | |
outputs: | |
get-version: ${{ steps.getversion.outputs.version }} | |
cluster-disk-image: ${{ steps.filter.outputs.cluster-disk-image }} | |
fc-env: ${{ steps.filter.outputs.fc-env }} | |
api-image: ${{ steps.filter.outputs.api-image }} | |
envd: ${{ steps.filter.outputs.envd }} | |
firecracker-task-driver: ${{ steps.filter.outputs.firecracker-task-driver }} | |
version: ${{ steps.filter.outputs.version }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get the last release | |
id: last_release | |
uses: cardinalby/git-get-release-action@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
latest: true | |
prerelease: false | |
draft: false | |
- name: Find changes since the last release | |
uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
base: ${{ steps.last_release.outputs.tag_name }} | |
filters: | | |
cluster-disk-image: | |
- 'packages/cluster-disk-image/**' | |
- '.github/workflows/cluster-disk-image.yml' | |
fc-env: | |
- 'packages/fc-env/**' | |
- '.github/workflows/fc-env.yml' | |
api-image: | |
- 'packages/api/**' | |
- '.github/workflows/api-image.yml' | |
envd: | |
- 'packages/envd/**' | |
- '.github/workflows/envd.yml' | |
firecracker-task-driver: | |
- 'packages/firecracker-task-driver/**' | |
- '.github/workflows/firecracker-task-driver.yml' | |
version: | |
- 'VERSION' | |
- name: Read Version file | |
id: getversion | |
run: echo "::set-output name=version::$(cat VERSION)" | |
firecracker-task-driver: | |
name: Devbook Firecracker Task Driver | |
needs: changes | |
if: | | |
needs.changes.outputs.version == 'true' && | |
needs.changes.outputs.firecracker-task-driver == 'true' | |
uses: ./.github/workflows/firecracker-task-driver.yml | |
secrets: | |
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} | |
service_account_email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} | |
cluster-disk-image: | |
name: Cluster disk image | |
needs: [changes, firecracker-task-driver] | |
if: | | |
always() && | |
needs.changes.outputs.version == 'true' && | |
(needs.changes.outputs.cluster-disk-image == 'true' || needs.firecracker-task-driver.result == 'success') | |
uses: ./.github/workflows/cluster-disk-image.yml | |
secrets: | |
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} | |
service_account_email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} | |
envd: | |
name: Devbook Daemon | |
needs: changes | |
if: | | |
needs.changes.outputs.version == 'true' && | |
needs.changes.outputs.envd == 'true' | |
uses: ./.github/workflows/envd.yml | |
secrets: | |
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} | |
service_account_email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} | |
version: ${{ needs.changes.outputs.get-version }} | |
fc-env: | |
name: FC env (pipeline scripts) | |
needs: changes | |
if: | | |
needs.changes.outputs.version == 'true' && | |
needs.changes.outputs.fc-env == 'true' | |
uses: ./.github/workflows/fc-env.yml | |
secrets: | |
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} | |
service_account_email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} | |
api-image: | |
name: API image | |
needs: changes | |
if: | | |
needs.changes.outputs.version == 'true' && | |
needs.changes.outputs.api-image == 'true' | |
uses: ./.github/workflows/api-image.yml | |
secrets: | |
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} | |
service_account_email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} | |
gce_project: ${{ secrets.GCE_PROJECT }} | |
terraform: | |
name: Terraform | |
needs: | |
[ | |
changes, | |
cluster-disk-image, | |
fc-env, | |
api-image, | |
envd, | |
firecracker-task-driver, | |
] | |
if: | | |
always() && | |
needs.changes.outputs.version == 'true' && | |
needs.changes.result == 'success' && | |
(needs.cluster-disk-image.result == 'success' || needs.cluster-disk-image.result == 'skipped') && | |
(needs.fc-env.result == 'success' || needs.fc-env.result == 'skipped') && | |
(needs.envd.result == 'success' || needs.envd.result == 'skipped') && | |
(needs.firecracker-task-driver.result == 'success' || needs.firecracker-task-driver.result == 'skipped') && | |
(needs.api-image.result == 'success' || needs.api-image.result == 'skipped') | |
uses: ./.github/workflows/terraform.yml | |
secrets: | |
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} | |
service_account_email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} | |
# The last succeesful release is used for determining which changed and what should be deployed in this release. | |
release: | |
name: Release | |
needs: [changes, terraform] | |
if: | | |
always() && | |
needs.terraform.result == 'success' && | |
needs.changes.outputs.version == 'true' | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Create release | |
uses: ncipollo/release-action@v1 | |
with: | |
name: Devbook API v${{ needs.changes.outputs.get-version }} | |
tag: v${{ needs.changes.outputs.get-version }} | |
commit: master | |
generateReleaseNotes: true | |
# TODO: Add release artifacts for envd |