feat: update env handling and add orchestration support (#65) #74
This file contains hidden or 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: Pack Virtual Machine Images | |
| on: | |
| push: | |
| branches: | |
| - main | |
| repository_dispatch: | |
| types: [trigger-workflow] | |
| workflow_dispatch: | |
| inputs: | |
| service: | |
| required: true | |
| description: 'The service to build' | |
| type: choice | |
| options: | |
| - dibbs-ecr-viewer | |
| - dibbs-query-connector | |
| version: | |
| required: true | |
| type: string | |
| description: 'The version of the service to build' | |
| default: 'main' | |
| concurrency: | |
| group: packerMachines | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| workflow_changes: | |
| with: | |
| what_to_check: ./.github | |
| uses: ./.github/workflows/checkForChanges.yml | |
| packer_changes: | |
| with: | |
| what_to_check: ./packer | |
| uses: ./.github/workflows/checkForChanges.yml | |
| docs_build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/build-docs | |
| packer_build_changes: | |
| # has changes, or push on main and not a workflow_dispatch or repository_dispatch | |
| if: (needs.workflow_changes.outputs.has_changes == 'true' || needs.packer_changes.outputs.has_changes == 'true' || github.ref == 'refs/heads/main') && (github.event_name != 'workflow_dispatch' || github.event_name != 'repository_dispatch') | |
| runs-on: ubuntu-latest | |
| needs: [ docs_build ] | |
| strategy: | |
| matrix: | |
| service: ['dibbs-ecr-viewer', 'dibbs-query-connector'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # AWS Authentication | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v2 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: Authenticate to Azure | |
| uses: azure/login@v2 | |
| with: | |
| creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}' | |
| - name: Set up Azure authentication for Packer | |
| run: | | |
| echo "ARM_CLIENT_ID=${{ secrets.AZURE_CLIENT_ID }}" >> $GITHUB_ENV | |
| echo "ARM_CLIENT_SECRET=${{ secrets.AZURE_CLIENT_SECRET }}" >> $GITHUB_ENV | |
| echo "ARM_SUBSCRIPTION_ID=${{ secrets.AZURE_SUBSCRIPTION_ID }}" >> $GITHUB_ENV | |
| echo "ARM_TENANT_ID=${{ secrets.AZURE_TENANT_ID }}" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Set up Packer | |
| uses: hashicorp/setup-packer@1aa358be5cf73883762b302a3a03abd66e75b232 | |
| with: | |
| version: 1.11.2 | |
| - name: Install Supporting Packages | |
| run: sudo apt-get update && sudo apt-get install -y qemu-system-x86 openssl | |
| - name: Run `packer init` | |
| working-directory: ./packer/ubuntu-server | |
| run: packer init . | |
| - name: Run `packer validate` | |
| working-directory: ./packer/ubuntu-server | |
| run: packer validate --var dibbs_service=${{ matrix.service }} --var dibbs_version=main . | |
| - name: Run `packer build` | |
| working-directory: ./packer/ubuntu-server | |
| run: packer build --var dibbs_service=${{ matrix.service }} --var dibbs_version=main . | |
| packer_build_repository_dispatch: | |
| if: github.event_name == 'repository_dispatch' | |
| runs-on: ubuntu-latest | |
| needs: [ docs_build ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # AWS Authentication | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v2 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: login into Azure | |
| uses: azure/login@v2 | |
| with: | |
| creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}' | |
| - name: Set up Azure authentication for Packer | |
| run: | | |
| echo "ARM_CLIENT_ID=${{ secrets.AZURE_CLIENT_ID }}" >> $GITHUB_ENV | |
| echo "ARM_CLIENT_SECRET=${{ secrets.AZURE_CLIENT_SECRET }}" >> $GITHUB_ENV | |
| echo "ARM_SUBSCRIPTION_ID=${{ secrets.AZURE_SUBSCRIPTION_ID }}" >> $GITHUB_ENV | |
| echo "ARM_TENANT_ID=${{ secrets.AZURE_TENANT_ID }}" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Set up Packer | |
| uses: hashicorp/setup-packer@1aa358be5cf73883762b302a3a03abd66e75b232 | |
| with: | |
| version: 1.11.2 | |
| - name: Install QEMU | |
| run: sudo apt-get update && sudo apt-get install -y qemu-system-x86 | |
| - name: Run `packer init ${{ github.event.client_payload.service }}` | |
| working-directory: ./packer/ubuntu-server | |
| run: packer init . | |
| - name: Run `packer validate ${{ github.event.client_payload.service }}` | |
| working-directory: ./packer/ubuntu-server | |
| run: packer validate --var dibbs_service=${{ github.event.client_payload.service }} --var dibbs_version=${{ github.event.client_payload.version }} . | |
| - name: Run `packer build ${{ github.event.client_payload.service }}` | |
| working-directory: ./packer/ubuntu-server | |
| run: packer build --var dibbs_service=${{ github.event.client_payload.service }} --var dibbs_version=${{ github.event.client_payload.version }} . | |
| packer_build_workflow_dispatch: | |
| if: github.event_name == 'workflow_dispatch' | |
| needs: [ docs_build ] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - provisioners: ${{ inputs.provisioners }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # AWS Authentication | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v2 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: login into Azure | |
| uses: azure/login@v2 | |
| with: | |
| creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}' | |
| - name: Set up Azure authentication for Packer | |
| run: | | |
| echo "ARM_CLIENT_ID=${{ secrets.AZURE_CLIENT_ID }}" >> $GITHUB_ENV | |
| echo "ARM_CLIENT_SECRET=${{ secrets.AZURE_CLIENT_SECRET }}" >> $GITHUB_ENV | |
| echo "ARM_SUBSCRIPTION_ID=${{ secrets.AZURE_SUBSCRIPTION_ID }}" >> $GITHUB_ENV | |
| echo "ARM_TENANT_ID=${{ secrets.AZURE_TENANT_ID }}" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Set up Packer | |
| uses: hashicorp/setup-packer@1aa358be5cf73883762b302a3a03abd66e75b232 | |
| with: | |
| version: 1.11.2 | |
| - name: Install QEMU | |
| run: sudo apt-get update && sudo apt-get install -y qemu-system-x86 | |
| - name: Run `packer init ${{ inputs.service }}` | |
| working-directory: ./packer/ubuntu-server | |
| run: packer init . | |
| - name: Run `packer validate ${{ inputs.service }}` | |
| working-directory: ./packer/ubuntu-server | |
| run: packer validate --var dibbs_service=${{ inputs.service }} --var dibbs_version=${{ inputs.version }} . | |
| - name: Run `packer build ${{ inputs.service }}` | |
| working-directory: ./packer/ubuntu-server | |
| run: packer build --var dibbs_service=${{ inputs.service }} --var dibbs_version=${{ inputs.version }} . | |
| ## TODO: Decide how to export artifact. |