[IRBuilder] Refactor FMF interface (#121657)
[llvm-project.git] / .github / workflows / build-ci-container-windows.yml
blobbba34066a97cd2499ed54455780333d4dc0fba20
1 name: Build Windows CI Container
3 permissions:
4   contents: read
6 on:
7   push:
8     branches:
9       - main
10     paths:
11       - .github/workflows/build-ci-container-windows.yml
12       - '.github/workflows/containers/github-action-ci-windows/**'
13   pull_request:
14     branches:
15       - main
16     paths:
17       - .github/workflows/build-ci-container-windows.yml
18       - '.github/workflows/containers/github-action-ci-windows/**'
20 jobs:
21   build-ci-container-windows:
22     if: github.repository_owner == 'llvm'
23     runs-on: windows-2019
24     outputs:
25       container-name: ${{ steps.vars.outputs.container-name }}
26       container-name-tag: ${{ steps.vars.outputs.container-name-tag }}
27       container-filename: ${{ steps.vars.outputs.container-filename }}
28     steps:
29       - name: Checkout LLVM
30         uses: actions/checkout@v4
31         with:
32           sparse-checkout: .github/workflows/containers/github-action-ci-windows
33       - name: Write Variables
34         id: vars
35         run: |
36           $tag = [int64](Get-Date -UFormat %s)
37           $container_name="ghcr.io/$env:GITHUB_REPOSITORY_OWNER/ci-windows-2019"
38           echo "container-name=${container_name}" >> $env:GITHUB_OUTPUT
39           echo "container-name-tag=${container_name}:${tag}" >> $env:GITHUB_OUTPUT
40           echo "container-filename=ci-windows-${tag}.tar" >> $env:GITHUB_OUTPUT
41       - name: Build Container
42         working-directory: .github/workflows/containers/github-action-ci-windows
43         run: |
44           docker build -t ${{ steps.vars.outputs.container-name-tag }} .
45       - name: Save container image
46         run: |
47           docker save  ${{ steps.vars.outputs.container-name-tag }} >  ${{ steps.vars.outputs.container-filename }}
48       - name: Upload container image
49         uses: actions/upload-artifact@v4
50         with:
51           name: container
52           path: ${{ steps.vars.outputs.container-filename }}
53           retention-days: 14
54   
55   push-ci-container:
56     if: github.event_name == 'push'
57     needs:
58       - build-ci-container-windows
59     permissions:
60       packages: write
61     runs-on: windows-2019
62     env:
63       GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64     steps:
65       - name: Download container
66         uses: actions/download-artifact@v4
67         with:
68           name: container
69       - name: Push Container
70         run: |
71           docker load -i ${{ needs.build-ci-container-windows.outputs.container-filename }}
72           docker tag ${{ needs.build-ci-container-windows.outputs.container-name-tag }} ${{ needs.build-ci-container-windows.outputs.container-name }}:latest
73           docker login -u ${{ github.actor }} -p $env:GITHUB_TOKEN ghcr.io
74           docker push ${{ needs.build-ci-container-windows.outputs.container-name-tag }}
75           docker push ${{ needs.build-ci-container-windows.outputs.container-name }}:latest