Merge pull request #14 from ifspcbt-devspace/develop #16
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: Tickets IFSP WEB - GHCR | |
on: | |
push: | |
branches: | |
- main | |
- homolog | |
jobs: | |
docker-build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to GitHub Container Registry | |
run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin | |
- name: Set branch-specific tag | |
id: tag | |
run: | | |
if [[ "${{ github.ref_name }}" == "main" ]]; then | |
echo "Running on default branch 'main': tag = 'latest'" | |
echo "tag=latest" >> $GITHUB_ENV | |
else | |
echo "Running on branch '${{ github.ref_name }}': tag = '${{ github.ref_name }}'" | |
echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV | |
fi | |
- name: Build and push Docker image | |
run: | | |
docker build --pull -t ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ env.tag }} . | |
docker push ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ env.tag }} | |
- name: Clean up Docker images | |
run: | | |
docker rmi ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ env.tag }} || true |