Build and Push to ECR #259
Workflow file for this run
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: Build and Push to ECR | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
env: | |
# Dagger | |
DAGGER_PLAN: cue.mod/pkg/github.com/3box/pipeline-tools/ci/plans/e2e.cue | |
DAGGER_LOG_FORMAT: "plain" | |
# Secrets | |
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
# Miscellaneous | |
SHA: ${{ github.sha }} | |
jobs: | |
run: | |
name: Build and Push to ECR | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v2 | |
- | |
name: Set sha tag | |
run: | | |
SHA_TAG=$(echo ${{ env.SHA }} | head -c 12) | |
echo "SHA_TAG=$SHA_TAG" >> $GITHUB_ENV | |
- | |
name: Install Dagger | |
uses: dagger/dagger-for-github@v3 | |
with: | |
install-only: true | |
version: "0.2.36" | |
- | |
name: Setup Dagger | |
run: | | |
dagger project init | |
dagger project update | |
dagger project update "github.com/3box/pipeline-tools/ci" | |
- | |
name: Push private Docker image | |
run: dagger do push -w "actions:push:\"${{ env.AWS_REGION }}\":\"${{ env.SHA }}\":\"${{ env.SHA_TAG }}\":_" -p ${{ env.DAGGER_PLAN }} | |
- | |
name: Login to public ECR | |
uses: docker/login-action@v2 | |
with: | |
registry: public.ecr.aws | |
username: ${{ env.AWS_ACCESS_KEY_ID }} | |
password: ${{ env.AWS_SECRET_ACCESS_KEY }} | |
env: | |
AWS_REGION: us-east-1 | |
- | |
name: Push public Docker image | |
run: | | |
docker buildx build --load -t 3box/ceramic-e2e-tests . | |
docker tag 3box/ceramic-e2e-tests:latest public.ecr.aws/r5b3e0r5/3box/ceramic-e2e-tests:latest | |
docker push public.ecr.aws/r5b3e0r5/3box/ceramic-e2e-tests:latest |