Deploy #120
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: Deploy | |
on: | |
push: | |
branches: ["main", "future"] | |
pull_request: | |
branches: ["main", "future"] | |
schedule: | |
- cron: '20 8 * * 1' | |
workflow_dispatch: | |
env: | |
AWS_REGION: "us-east-1" | |
permissions: | |
id-token: write | |
contents: read | |
packages: write | |
jobs: | |
base: | |
name: Build and deploy the base Alpine image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@main | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: linux/arm64 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }} | |
with: | |
aws-region: ${{ env.AWS_REGION }} | |
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
role-duration-seconds: 900 | |
- name: Install latest AWS CLI | |
uses: unfor19/install-aws-cli-action@v1 | |
- name: Login to Amazon ECR | |
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }} | |
run: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${REPOSITORY_PATH} | |
env: | |
REPOSITORY_PATH: ${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }} | |
- name: Log in to GitHub registry | |
uses: docker/login-action@v3 | |
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }} | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push the image | |
uses: docker/build-push-action@v6 | |
with: | |
context: base | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }} | |
tags: | | |
${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }}:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }} | |
ghcr.io/spacelift-io/runner-ansible:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }} | |
aws: | |
needs: base | |
name: Build and deploy the alpine base AWS image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@main | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: linux/arm64 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }} | |
with: | |
aws-region: ${{ env.AWS_REGION }} | |
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
role-duration-seconds: 900 | |
- name: Install latest AWS CLI | |
uses: unfor19/install-aws-cli-action@v1 | |
- name: Login to Amazon ECR | |
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }} | |
run: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${REPOSITORY_PATH} | |
env: | |
REPOSITORY_PATH: ${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_AWS }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push the image | |
uses: docker/build-push-action@v6 | |
with: | |
build-args: | | |
REPOSITORY_BASE_PATH=${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }} | |
context: aws | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }} | |
tags: | | |
${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_AWS }}:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }} | |
gcp: | |
needs: base | |
name: Build and deploy the alpine base GCP image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@main | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: linux/arm64 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }} | |
with: | |
aws-region: ${{ env.AWS_REGION }} | |
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
role-duration-seconds: 900 | |
- name: Install latest AWS CLI | |
uses: unfor19/install-aws-cli-action@v1 | |
- name: Login to Amazon ECR | |
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }} | |
run: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${REPOSITORY_PATH} | |
env: | |
REPOSITORY_PATH: ${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_GCP }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push the image | |
uses: docker/build-push-action@v6 | |
with: | |
build-args: | | |
REPOSITORY_BASE_PATH=${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }} | |
context: aws | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/future' }} | |
tags: | | |
${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL_GCP }}:${{ github.ref == 'refs/heads/main' && 'latest' || 'future' }} |