Delete .github/workflows/main_az-appservice-go-azureregistry.yml #46
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: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
GOOS: linux | |
GOARCH: amd64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.21.x | |
cache: false | |
- name: Get Go cached paths | |
run: | | |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV | |
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV | |
- name: Set up dependencies cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ env.cache }} | |
key: setup-go-deps-${{ runner.os }}-go-${{ hashFiles('go.sum', 'go.mod') }} | |
- run: echo "$GOOS $GOARCH" > env.txt | |
- name: Set up intermediate built files cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ env.modcache }} | |
key: setup-go-build-${{ env.GOOS }}-${{ env.GOARCH }}-${{ runner.os }}-go-${{ hashFiles('**/*.go', 'env.txt') }} | |
restore-keys: | | |
setup-go-build-${{ env.GOOS }}-${{ env.GOARCH }}-${{ runner.os }}-go | |
- name: Build Linux binary | |
run: go build | |
- name: Build & tar docker image | |
if: ${{ true }} | |
run: | | |
docker build -t az-appservice-go . | |
docker save az-appservice-go |gzip > az-appservice-go.tar.gz | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: docker-image | |
path: az-appservice-go.tar.gz | |
choose-registry: | |
runs-on: ubuntu-latest | |
env: | |
dockerhub: false | |
azureregistry: true | |
outputs: | |
dockerhub: ${{ steps.choose.outputs.dockerhub }} | |
azureregistry: ${{ steps.choose.outputs.azureregistry }} | |
steps: | |
- name: Choose container registry | |
id: choose | |
run: | | |
echo "dockerhub==${dockerhub}" >> $GITHUB_OUTPUT | |
echo "azureregistry==${azureregistry}" >> $GITHUB_OUTPUT | |
publish-to-registry: | |
needs: [build, choose-registry] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: docker-image | |
- name: Unar docker image | |
run: | | |
gunzip -c az-appservice-go.tar.gz| docker load | |
docker images | |
- name: Publish to Docker Hub | |
if: needs.choose-registry.outputs.dockerhub | |
run: | | |
docker tag az-appservice-go ${{ secrets.DOCKER_USERNAME }}/az-appservice-go | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} | |
docker push ${{ secrets.DOCKER_USERNAME }}/az-appservice-go | |
- name: Log in to Azure registry | |
if: needs.choose-registry.outputs.azureregistry | |
uses: docker/login-action@v2 | |
with: | |
registry: https://akvtraining.azurecr.io/ | |
username: ${{ secrets.AzureAppService_ContainerUsername_a3760a5dac7f4726917f38f215d0db06 }} | |
password: ${{ secrets.AzureAppService_ContainerPassword_02520bfd6ea841afbf108eca82268bd9 }} | |
#username: ${{ secrets.AZURE_REGISTRY_USER }} | |
#password: ${{ secrets.AZURE_REGISTRY_PASSWORD }} | |
- name: Publish to Azure Registry | |
if: needs.choose-registry.outputs.azureregistry | |
run: docker push akvtraining.azurecr.io/az-appservice-go | |
deplpoy-to-azure-from-dockerhub: | |
if: needs.choose-registry.outputs.dockerhub | |
needs: [publish-to-registry, choose-registry] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy az-appservice-go-dockerhub | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: az-appservice-go-dockerhub | |
publish-profile: ${{ secrets.APP_GO_DOCKERHUB_PROFILE }} | |