Skip to content

Only push latest to gitlab for ci #58

Only push latest to gitlab for ci

Only push latest to gitlab for ci #58

Workflow file for this run

name: Build and Release Deploy Azure Image
on:
push:
paths:
- 'deploy-azure/**'
- '.github/workflows/deploy-azure.yaml'
jobs:
release:
name: Build and Release Deploy Image
runs-on: ubuntu-latest
defaults:
run:
shell: bash
permissions:
id-token: write
contents: write
pull-requests: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Log in to the Github Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Test Build for deploy-azure
if: "${{ github.event_name == 'push' && ! contains(github.ref,'tag') }}"
uses: docker/build-push-action@v4
with:
context: deploy-azure
push: true
tags: ghcr.io/iaacautomation/deploy-azure:test
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Get tag
if: contains(github.ref,'tag')
id: tag
uses: dawidd6/action-get-tag@v1
with:
strip_v: true
- name: Log in to the Docker Container registry
if: contains(github.ref,'tag')
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_ACCOUNT }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to the Gitlab Container registry
if: contains(github.ref,'tag')
uses: docker/login-action@v2
with:
registry: registry.gitlab.com
username: ${{ secrets.GITLAB_ACCOUNT }}
password: ${{ secrets.GITLAB_TOKEN }}
- name: Configure AWS credentials
if: contains(github.ref,'tag')
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-region: us-east-1
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 900
role-session-name: GitHub
- name: Login to Amazon ECR
if: contains(github.ref,'tag')
run: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ secrets.ECR_REPO_PATH }}
- name: Build and Push images
if: contains(github.ref,'tag')
uses: docker/build-push-action@v4
with:
context: deploy-azure
push: true
tags: |
ghcr.io/iaacautomation/deploy-azure:${{steps.tag.outputs.tag}}
ghcr.io/iaacautomation/deploy-azure:latest
${{ secrets.GITLAB_REGISTRY_PATH }}/deploy-azure:latest
${{ secrets.DOCKERHUB_ACCOUNT }}/deploy-azure:${{steps.tag.outputs.tag}}
${{ secrets.DOCKERHUB_ACCOUNT }}/deploy-azure:latest
${{ secrets.ECR_REPO_PATH }}/deploy-azure:${{steps.tag.outputs.tag}}
${{ secrets.ECR_REPO_PATH }}/deploy-azure:latest
platforms: linux/amd64 ,linux/arm64
cache-from: type=gha