actions: test push docker image #23
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: CI | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build: | |
name: 'Build and Push' | |
runs-on: ubuntu-latest | |
# strategy: | |
# matrix: | |
# node: [ 16, 18, 20 ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
with: | |
version: 9 | |
run_install: false | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
# node-version: ${{ matrix.node}} | |
# cache: 'pnpm' | |
- run: pnpm install && pnpm test | |
- name: Generate tag | |
id: generate_tag | |
run: | | |
SHA=$(echo $GITHUB_SHA | head -c7) | |
echo "sha=$SHA" >> $GITHUB_OUTPUT | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::327649228912:role/ecr-role | |
aws-region: us-east-1 | |
- name: Login to AWS ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build and push docker image | |
env: | |
REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
TAG: ${{ steps.generate_tag.outputs.sha }} | |
run: | | |
docker build -t $REGISTRY/nest-clean/05-nest-clean:$TAG . | |
docker push $REGISTRY/nest-clean/05-nest-clean:$TAG | |
# - name: Login into the container registry | |
# uses: docker/login-action@v3 | |
# with: | |
# username: ${{ secrets.DOCKERHUB_USERNAME }} | |
# password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# - name: Build and Push | |
# uses: docker/build-push-action@v5 | |
# with: | |
# push: true | |
# tags: pedrojorge148/05-nest-clean:${{ steps.generate_tag.outputs.sha }},pedrojorge148/05-nest-clean:latest | |
# - name: Build docker image | |
# run: docker build -t pedrojorge148/05-nest-clean:${{ steps.generate_tag.outputs.sha }} . | |
# - name: Push image | |
# run: | | |
# docker push pedrojorge148/05-nest-clean:${{ steps.generate_sha.outputs.sha }} | |
# docker tag pedrojorge148/05-nest-clean:${{ steps.generate_sha.outputs.sha }} pedrojorge148/05-nest-clean:latest | |
# docker push pedrojorge148/05-nest-clean:latest |