refacto: github actions #119
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 docker registry when pushing on staging or main | ||
permissions: | ||
packages: write | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- staging | ||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
jobs: | ||
build-and-push: | ||
environment: ${{ github.ref_name == 'main' && 'prod' || 'staging' }} | ||
name: Build and push from ${{ github.ref_name }}/${{ github.sha }} | ||
runs-on: ubuntu-latest | ||
env: | ||
IMAGE_NAME: ghcr.io/${{ github.repository }}/albert-tchap | ||
IMAGE_TAG: ${{ github.sha }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
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 | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }},${{ env.IMAGE_NAME }}:latest | ||
deploy-staging: | ||
on: | ||
Check failure on line 43 in .github/workflows/build_and_deploy.yml GitHub Actions / Build and push to docker registry when pushing on staging or mainInvalid workflow file
|
||
push: | ||
branches: | ||
- 'remove_deployment_from_github_actions' | ||
environment: ${{ github.ref_name == 'main' && 'prod' || 'staging' }} | ||
name: Deploy from ${{ github.ref_name }}/${{ github.sha }} | ||
runs-on: ubuntu-latest | ||
needs: build-and-push | ||
steps: | ||
- name: Trigger staging deployment | ||
run: | | ||
curl --request POST \ | ||
--form token=${{ secrets.GITLAB_CI_TOKEN }} \ | ||
--form ref=main \ | ||
--form "variables[docker_image_tag]=latest" \ | ||
--form "variables[application_to_deploy]=albert-tchap" \ | ||
--form "variables[deployment_environment]=staging" \ | ||
"https://gitlab.com/api/v4/projects/58117805/trigger/pipeline" |