coder-release #136
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
on: | |
repository_dispatch: | |
types: [coder-release] | |
workflow_dispatch: | |
inputs: | |
coder_version: | |
description: "Coder Version" | |
required: true | |
default: "x.x.x" | |
append_version: | |
description: 'Append version (e.g. ".1")' | |
default: "" | |
required: false | |
jobs: | |
packer_release: | |
runs-on: ubuntu-latest | |
name: packer | |
permissions: | |
contents: "read" | |
id-token: "write" | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set packer variables (repository_dispatch) | |
if: github.event_name == 'repository_dispatch' | |
run: | | |
echo "PKR_VAR_coder_version=${{ github.event.client_payload.coder_version }}" >> "$GITHUB_ENV" | |
echo "PKR_VAR_append_version=${{ github.event.client_payload.append_version }}" >> "$GITHUB_ENV" | |
- name: Set packer variables (workflow_dispatch) | |
if: github.event_name == 'workflow_dispatch' | |
run: | | |
echo "PKR_VAR_coder_version=${{ github.event.inputs.coder_version }}" >> "$GITHUB_ENV" | |
echo "PKR_VAR_append_version=${{ github.event.inputs.append_version }}" >> "$GITHUB_ENV" | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
workload_identity_provider: projects/912981742393/locations/global/workloadIdentityPools/github/providers/my-repo | |
service_account: coder-packages-ci@workspan-public-422119.iam.gserviceaccount.com | |
- name: Setup `packer` | |
uses: hashicorp/setup-packer@main | |
id: setup | |
with: | |
version: latest | |
- name: Run `packer init` | |
id: init | |
run: "packer init ./template.pkr.hcl" | |
- name: Run `packer validate` | |
id: validate | |
run: "packer validate ./template.pkr.hcl" | |
- name: Build Artifact | |
run: | | |
packer build \ | |
-force \ | |
-var "coder_version=${{ env.PKR_VAR_coder_version }}" \ | |
./template.pkr.hcl | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Submit AMI to AWS Marketplace | |
run: ./.github/workflows/aws/submit_ami.sh | |
continue-on-error: true | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: us-east-1 | |
VERSION: ${{ env.PKR_VAR_coder_version }} | |
MARKETPLACE_ACCESS_ROLE_ARN: ${{ secrets.AWS_MARKETPLACE_ACCESS_ROLE_ARN }} | |
PRODUCT_IDENTIFIER: ${{ secrets.AWS_PRODUCT_IDENTIFIER }} | |
- name: Submit image to GCP Marketplace | |
run: ./.github/workflows/gcp/submit_image.sh |